Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi I am looking for help on this question. Qn2. Write a complete C++ program to calculate area and circumference of a circle. Your program

Hi I am looking for help on this question.

Qn2. Write a complete C++ program to calculate area and circumference of a circle. Your program should have the following functions in addition to a main() function. 1. menu that displays Do you want to use radius or diameter for the calculation? Enter 1 for radius Enter 2 for diameter Enter -1 to exit

2. diameter_to_radius receives diameter (double) as a parameter and returns radius (double).

3. random_value_generator generates random values (double) between minimum and maximum.

4. area receives radius (double) as a parameter and returns area (double).

5. circumference - receives radius (double) as a parameter and returns circumference (double). You should start the program by prompting the user to select radius or diameter for the calculation (validate the choice).

Area of a circle is ????????2 and circumference of a circle is 2?r, where r is the radius of the circle. radius = diameter/2 Assume the value of ? is 3.14159.

radius: You should ask the user to choose a unit, either cm or m (validate the choice), for the calculation. Generate a random double value (use random_value_generator) between 5. 0 (minimum) and 15.0 (maximum) for the radius. Prompt the user to choose either area or circumference calculation (prompt by using character A for area and C for circumference validate choice).

diameter: You should ask the user to choose a unit, either cm or m (validate the choice), for the calculation. Generate a random double value (use random_value_generator) between 15.0 and 30.0 for the diameter. Before calculating area or circumference convert diameter to radius (use diameter_to_radius function).

You should exit the program only when the user inputs -1.

All results are printed in main, show only two decimal numbers in the final result.

The formatting of the output should be similar (including the units) to the screen shot shown.

In this task double means double precision floating point value.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions

Question

Explain the causes of indiscipline.

Answered: 1 week ago

Question

4-22. Glen monopolizes every meeting by being (a loudmouth)?

Answered: 1 week ago