Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write code in c++ that calculates and prints the diameter, the circumference, or the area of a circle, given the radius. The program inputs two

Write code in c++ that calculates and prints the diameter, the circumference, or the area of a circle, given the radius. The program inputs two data items. The first is a characterD (for diameter), C (for circumference), or A (for area)to indicate the calculation needed. The next data value is a floating-point number indicating the radius of the particular circle. The program should print the input data. The output should be labeled appropriately. For example, if the input is: A 6.75 your program should print something like this: The area of a circle with radius 6.75 is 143.14. Here are the formulas you need: Diameter = 2r, Circumference = 2r, Area of a circle = r2 where r is the radius. Use 3.14159265 for . Modify your program to perform input validation by making sure that the first character is A or C or D and the value of the radius is greater than zero. An appropriate error message should be printed if invalid data was entered.

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_2

Step: 3

blur-text-image_3

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

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

=+b. Would you need to edit down the copy for a smaller-space ad?

Answered: 1 week ago