Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that will compute the average of a set of decimal numbers provid

ID: 3659269 • Letter: W

Question

Write a program that will compute the average of a set of decimal numbers provided by the user. The program will ask the user to enter numbers one at a time.

The user will enter numbers and the program will keep a count of the numbers entered. At the end, the program will display the sum, the count and the average of the numbers. See Test section below for test data.

Implementation

Use cin for inputing numbers. When the user presses ctrl-z followed by return key twice, cin becomes NULL.

Testing

Input Test Run 1

Enter a number:

10.2

Enter a number:

50.4

Enter a number:

40.6

Enter a number:

20.8

Enter a number:

30.0

Enter a number:

Output Test Run 1

Sum: 152.0

Count: 5

Average: 30.4

Explanation / Answer

#include using namespace std; int main() { int count=0; double sum=0; double average; double input; coutinput; while(cin) { count++; sum+=input; coutinput; } average = sum/count; cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote