Problem

(Practice) Rewrite Program to display this prompt: Please type in the total number of data...

(Practice) Rewrite Program to display this prompt: Please type in the total number of data values to be added: In response to this prompt, the program should accept a user-entered number, and then use this number to control the number of times the while loop is executed. So if the user enters 5 in response to the prompt, the program should request input of five numbers and display the total after five numbers have been entered.

Program:

#include #include using namespace std;int main( ){const int MAXNUMS = 4;int count;double num, total;cout << "\nThis program will ask you to enter "<< MAXNUMS << " numbers.\n";count = 1;total = 0;while (count <= MAXNUMS){cout << "\nEnter a number: ";cin >> num;total = total + num;cout << "The total is now " << setprecision(7) << total;count++;}cout << "\nThe final total is " << setprecision(7) << total << endl;return 0;}

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 5.2