Question: Write a program that displays the following menu. The symbols show where newline characters ( ) should be displayed: Geometry Calculator 1. Calculate the Area

Write a program that displays the following menu. The symbols show where newline characters (" ") should be displayed: Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1-4): If the user enters 1: The program should print the following string as a prompt: " Enter the circle's radius: " The program should then read the radius of the circle as input and then calculate the circle's area using the following formula: Area = r2 In your calculation, use 3.14159 for and the radius of the circle for r. The program should then print the string " The area is ", followed by the area, followed by a newline. If the user enters 2: The program should print the following string as a prompt: " Enter the rectangle's length: " The program should read the length as input and then print the following string as a prompt: "Enter the rectangle's width: " The program should read the width as input and then calculate the rectangle's area using the following formula: Area = length width The program should then print the string " The area is ", followed by the area, followed by a newline. If the user enters 3: The program should print the following string as a prompt: "Enter the length of the base: " The program should read the base as input and then print the following string as a prompt: "Enter the triangle's height: " The program should read the height as input and then calculate the triangle's area using the following formula: Area = base height 0.5 The program should then print the string " The area is ", followed by the area, followed by a newline. If the user enters 4: The program should print the string "Program ending. ", and then end. Input Validation: The only valid menu choices the user can make are 1, 2, 3, or 4. If the user makes a menu choice other than one of these numbers, the program should print the following strings and then end: "The valid choices are 1 through 4. Run the " "program again and select one of those. " If the user enters a negative number for the circle's radius, print the following string, and then end: " The radius can not be less than zero. " If the user enters a negative number for the rectangle's length OR width, print the following string, and then end: " Only enter positive values for length and width. " If the user enters a negative number for the triangle's base OR height, print the following string, and then end: " Only enter positive values for base and height. " Sample Run Geometry Calculator 1. Calculate the area of a Circle 2. Calculate the area of a Rectangle 3. Calculate the area of a Triangle 4. Quit Enter your choice (1-4): 1 Enter the circle's radius: 1 The area is 3.14159 Sample Run Geometry Calculator 1. Calculate the area of a Circle 2. Calculate the area of a Rectangle 3. Calculate the area of a Triangle 4. Quit Enter your choice (1-4): 2 Enter the rectangle's length: 10 Enter the rectangle's width: 20 The area is 200

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!