Write a C++ program that will prompt the user for the radius for 4 different circles. The formula to calculate the area of a circle is: area = PI * radius * radius Once the areas of the circles have been calculated to 2 decimal places, display the average circle area along with the circle with the largest area and the circle with the smallest area. The radius value entered must be between 1 - 10000 cm. Any value outside this range should be captured and allow the user one more attempt to enter the radius. your program will need to test for valid input. Valid input means 3 things in this program: 1. Test scores cannot be greater than 10000 2. Test scores cannot be zero or negative. 3. Only numeric values can be entered. Be sure to: use the template code at the beginning of your program use constant variables where appropriate comment throughout your code move the VS code away from your output add appropriate heading/ending statement to the output if the user inputs an invalid value, display an appropriate error message and allow the user another attempt to enter the radius
Write a C++
The formula to calculate the area of a circle is:
area = PI * radius * radius
Once the areas of the circles have been calculated to 2 decimal places, display the average circle area along with the circle with the largest area and the circle with the smallest area.
The radius value entered must be between 1 - 10000 cm. Any value outside this range should be captured and allow the user one more attempt to enter the radius.
your program will need to test for valid input. Valid input means 3 things in this program:
1. Test scores cannot be greater than 10000
2. Test scores cannot be zero or negative.
3. Only numeric values can be entered.
Be sure to:
- use the template code at the beginning of your program
- use constant variables where appropriate
- comment throughout your code
- move the VS code away from your output
- add appropriate heading/ending statement to the output
- if the user inputs an invalid value, display an appropriate error message and allow the user another attempt to enter the radius
Algorithm :
1. Start
2. Declare variables for the largest area, smallest area, total area, and number of circles.
3. Set the largest area and smallest area to 0 and max, respectively.
4. Prompt user to input the radius of each circle.
5. Calculate the area of each circle using the radius and PI.
6. Accumulate the total area by adding the area of each circle.
7. Compare the area of each circle with the largest area and smallest area.
8. If the area of the circle is larger than the current largest area, set the largest area to the new area.
9. If the area of the circle is smaller than the current smallest area, set the smallest area to the new area.
10. Calculate the average area by dividing the total area by the number of circles.
11. Print the average area, largest area, and smallest area.
12. Stop
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images
i need a error message for when the user enters a value too high, a negative value, or a letter.
I need to also calculate and display the area of each circle. Also, i need a different error message for when letters are used for input.