CSCI 240 Fall 2025

Assignment 5
Loops and Decision Statements
(100 points)


Due: Friday, October 10 on the autograder and Blackboard by 11:59 PM

Overview

For this assignment, write a C++ program that will calculate a set of statistics for an unknown number of small randomly sized sets of random numbers.

The statistics that will be calculated:

The cpp file that is submitted for grading must be named assign5.cpp.

Random Number Generation

As with assignment 4, the random number generator will be used to determine the size of the sets and the values in the sets.

This assignment will use:

If a reminder is needed about how to use the random number generator and how to limit the values that are produced, refer back to assignment 4:

Link to Assignment 4

Basic Program Logic

Ask the user to enter the seed value for the random number generator and use it with the srand() instruction.

In a loop that executes as long as the user wants to display a set of values and calculate the statistics:

Standard Deviation

The standard deviation is calculated as follows:

where

For example, if a set contains 4 numbers:

7   3   4   5

then

Program Requirements

  1. Make and use meaningful variable names.

  2. Use the sqrt() function when calculating the standard deviation. Don't forget to #include <cmath>.

  3. Hand in a copy of the source code (the CPP file) on the autograder and Blackboard.

Formatting Help

  1. The display of random numbers in a set should start with exactly two newline characters.

  2. The individual random numbers should be displayed in a field of 5 characters.

  3. The labels for the statistics should all be preceded by exactly 2 spaces.

  4. The statistics are displayed in fields of exactly 17, 25, 26, 30, 26, and 15 characters.

Output

Windows PC

Seed Value? 5


The random numbers are:   94   56   50   61   31   28   50   73   41   15   22   34   77   27
  Number of Values:               14
  Smallest:                       15
  Largest:                        94
  Sum:                           659
  Average:                     47.07
  Standard Deviation:          23.12

Again (Y/N)? y


The random numbers are:   64    8   51   32   18   93   94   12   37   50   53
  Number of Values:               11
  Smallest:                        8
  Largest:                        94
  Sum:                           512
  Average:                     46.55
  Standard Deviation:          29.30

Again (Y/N)? Y


The random numbers are:   23   32   52
  Number of Values:                3
  Smallest:                       23
  Largest:                        52
  Sum:                           107
  Average:                     35.67
  Standard Deviation:          14.84

Again (Y/N)? y


The random numbers are:   60   11   54   16   23
  Number of Values:                5
  Smallest:                       11
  Largest:                        60
  Sum:                           164
  Average:                     32.80
  Standard Deviation:          22.60

Again (Y/N)? n

Mac

Seed Value? 5


The random numbers are:   46   25   97   57   14   21   50   75   58
  Number of Values:                9
  Smallest:                       14
  Largest:                        97
  Sum:                           443
  Average:                     49.22
  Standard Deviation:          26.74

Again (Y/N)? Y


The random numbers are:   32   73   11
  Number of Values:                3
  Smallest:                       11
  Largest:                        73
  Sum:                           116
  Average:                     38.67
  Standard Deviation:          31.53

Again (Y/N)? y


The random numbers are:   22   95   46   54   61   22    5   52   98
  Number of Values:                9
  Smallest:                        5
  Largest:                        98
  Sum:                           455
  Average:                     50.56
  Standard Deviation:          31.77

Again (Y/N)? y


The random numbers are:   72   96   50   87   35   98   90   14   36   10
  Number of Values:               10
  Smallest:                       10
  Largest:                        98
  Sum:                           588
  Average:                     58.80
  Standard Deviation:          34.02

Again (Y/N)? n

onlinegdb

Seed Value? 5


The random numbers are:   66   11   73
  Number of Values:                3
  Smallest:                       11
  Largest:                        73
  Sum:                           150
  Average:                     50.00
  Standard Deviation:          33.96

Again (Y/N)? Y


The random numbers are:   33   21
  Number of Values:                2
  Smallest:                       21
  Largest:                        33
  Sum:                            54
  Average:                     27.00
  Standard Deviation:           8.49

Again (Y/N)? y


The random numbers are:   74   82   27
  Number of Values:                3
  Smallest:                       27
  Largest:                        82
  Sum:                           183
  Average:                     61.00
  Standard Deviation:          29.72

Again (Y/N)? Y


The random numbers are:   61   99   11   21   21   27   29   87   15    6
  Number of Values:               10
  Smallest:                        6
  Largest:                        99
  Sum:                           377
  Average:                     37.70
  Standard Deviation:          32.85

Again (Y/N)? n