222k views
4 votes
Set a variable called total to 0. Ask the user to enter five numbers using a loop and after each input ask them if they want that number included. If they do, then add the number to the total. If they do not want it included, don't add it to the total. After they have entered all five numbers, display the total.

1 Answer

3 votes

Final answer:

The question involves creating a program that calculates a total based on user input, asking after each number whether it should be included in the sum.

Step-by-step explanation:

The task presented involves setting a variable total to 0 and using a loop to ask the user for five numbers. For each number input by the user, the program should ask whether to include the number in the calculation of total. If the user wants the number included, it should be added to the total; otherwise, it should not be added. After collecting five numbers this way, the final total should be displayed to the user.

User Dilini Rajapaksha
by
7.2k points

No related questions found