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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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
Expert Solution
Step 1

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

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

i need a error message for when the user enters a value too high, a negative value, or  a letter.

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

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.

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education