Question
C++ Please Follow Instructions Counter-Controlled While Loop Lab Write a program that does the following: Prompts the user for the number of grades they wish
C++
Please Follow Instructions
Counter-Controlled While Loop Lab
Write a program that does the following:
- Prompts the user for the number of grades they wish to enter.
- Computes a running total of the grades entered. You will need to initialize this variable to zero when you declare it.
- Calculates the average of the grades entered.
- Test to make sure the average is not computed if the number of grades is zero.
- Prints out one of the following:
- A message stating the average of the grades entered.
- An error message stating that the number of grades must be greater than zero.
Include the following:
0. If the User enters a zero or less for the number of grades then print out an error message stating that the number of grades must be greater than zero.
1. Initialize the counter to either zero or one before the while loop begins.
2. Use a counter controlled while loop that uses the number of grades entered by the User as the maximum number of loops executed.
a. If you initialized your counter to zero you will want the loop to continue as long as your counter is less than the number of grades.
b. If you initialized your counter to one you will want the loop to continue as long as your counter is less than or equal to the number of grades.
3. Within the body of the loop:
a. Prompts the User for the next grade.
b. Compute a running total of these grades as they are entered.
4. After the While Loop is done executing, compute the average of all the grades entered. Remember to check to make sure you don't perform a division by zero.
5. Include all Prologue information.
6. Include an initial algorithm.
7. Include a refined algorithm.
NOTE: 1. Declare all variables within the data declaration section. ( -.1) points 2 Do not get input on the same line as a variable declaration. ( -.1) points 3. Do not place an equation for computation on the same line as declaring a variable. ( -.1) points
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started