Answered step by step
Verified Expert Solution
Link Copied!

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

image

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 ... 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

Matlab An Introduction with Applications

Authors: Amos Gilat

5th edition

1118629868, 978-1118801802, 1118801806, 978-1118629864

More Books

Students also viewed these Programming questions

Question

How is financial modeling applied to mergers and acquisitions?

Answered: 1 week ago

Question

2. Explain the goals of research.

Answered: 1 week ago