Question: Write a program that calculates the area for a number of different shapes. Create a method to ask the user if they want to

Write a program that calculates the area for a number of different

Write a program that calculates the area for a number of different shapes. Create a method to ask the user if they want to calculate the area for a circle, a rectangle, or a triangle. If the user answers something other than the letters 'c', 'r' or 't', ask them again. Keep asking them until they enter valid input. Return the shape to the main method. Depending on the shape, your main method will execute a different method The circle method will ask for a radius and return the area of the circle (area= 0.5 *3.14* radius *radius) back to the main method. The rectangle method will ask for a length and a width, calculate area=length*width, and return the area to the main method. The triangle method will ask for a base and a height, calculate (area= 0.5 * base*height), and return the area to the main method. When the main method receives the area, it will print it out the user.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a simple Python program that follows the specified requirements import math def getuserchoice ... View full answer

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 Programming Questions!