Problem 1 - Min, Mean, Max
Write a program that reads in successive integer values from the user. The user will indicate termination of these values with the sentinel value 0 (zero). After the program has read in the values, the program will output the minimum value entered, the maximum value entered, and the mean (average) of the values entered (to two decimal places). If the user does not enter any numbers before entering 0, the program will display the message "No numbers were read".
Sample outputs:
Please enter some integers, and a 0 (zero) to terminate:
1 2 3 4 5 0
The minimum number entered was 1
The maximum number entered was 5
The mean of the numbers was 3.00
Press any key to continue . . .
Please enter some integers, and a 0 (zero) to terminate:
1 2 3 4 5 6 7 8 9 10 0
The minimum number entered was 1
The maximum number entered was 10
The mean of the numbers was 5.50
Press any key to continue . . .
Please enter some integers, and a 0 (zero) to terminate:
0
No numbers were read.
Press any key to continue . . .
You may assume that the user enters a valid integer.
this is what i have so far although i dont really have a clue what im doing help most appreciated:)
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
cout << "Please enter some integers, and a 0 (zero) to terminate:" <<endl;
int num;
do
{
int num;
cin >> num;
if (num =0)
{
cout << "No numbers were read." << endl;
}
else;
}
while (num !=0)
{
int minimum;
int count = 0;
count++; //Add one to count
}
cout << count << endl;
return 0;
}
Write a program that reads in successive integer values from the user. The user will indicate termination of these values with the sentinel value 0 (zero). After the program has read in the values, the program will output the minimum value entered, the maximum value entered, and the mean (average) of the values entered (to two decimal places). If the user does not enter any numbers before entering 0, the program will display the message "No numbers were read".
Sample outputs:
Please enter some integers, and a 0 (zero) to terminate:
1 2 3 4 5 0
The minimum number entered was 1
The maximum number entered was 5
The mean of the numbers was 3.00
Press any key to continue . . .
Please enter some integers, and a 0 (zero) to terminate:
1 2 3 4 5 6 7 8 9 10 0
The minimum number entered was 1
The maximum number entered was 10
The mean of the numbers was 5.50
Press any key to continue . . .
Please enter some integers, and a 0 (zero) to terminate:
0
No numbers were read.
Press any key to continue . . .
You may assume that the user enters a valid integer.
this is what i have so far although i dont really have a clue what im doing help most appreciated:)
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
cout << "Please enter some integers, and a 0 (zero) to terminate:" <<endl;
int num;
do
{
int num;
cin >> num;
if (num =0)
{
cout << "No numbers were read." << endl;
}
else;
}
while (num !=0)
{
int minimum;
int count = 0;
count++; //Add one to count
}
cout << count << endl;
return 0;
}
Comment