Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Heres a simple Python program that follows the specified requirements import math def getuserchoice ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started