Write a program that calculates the area for a number of different shapes. Create a method...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
Heres a simple Python program that follows the specified requirements import math def getuserchoice ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Due to the rapid growth of your technology company, the executive team has asked HR to develop an internal training program. The purpose of the program is to help employees recently promoted to...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
What immediate clinical concerns does this client present to the counselor or therapist? Are there sufficient symptoms presented in the case to make a diagnosis of either stimulant and/or alcohol use...
-
Information for Schopp Corporation is given in E8-5. In E8-5 Schopp Corporation makes a mechanical stuffed alligator that sings the Martian national anthem. The following information is available for...
-
How do hormones influence developmental processes, including cell fate determination, tissue differentiation, and morphogenetic patterning, and what are the key regulatory networks involved in...
-
The 2008 comparative balance sheet and income statement of Digital Subscriptions, Inc.. follow. Digital Subscriptions had no noncash investing and financing trans- actions during 2008. During the...
-
A major focus of the trial in this case was BDO Seidmans consideration of, and response to, the red flags apparent during the 1995 HMI audit. Define or describe the phrase red flags. Explain the...
-
Consider the following information about pharmaceutical companies: Company Ticker Price per Share Earnings per Share Book Value per Share Abbott Labs ABT 54.35 2.69 13.79 Bristol-Myers-Squibb BMY...
-
Refer to the North Valley Real Estate data, which report information on homes sold during the last year. For the variable price, select an appropriate class interval and organize the selling prices...
-
Find the amount. 1 What is 82% of $5980? 1 2% of $5980 is $ (Type an integer or a decimal.)
-
15. (4 points) A solid object has a weight of 23.3 N. When it is suspended from a scale and submerged in oil of density 925 kg/m, the scale reads 12.9 N. Find the object's density. or to beans
-
Huron Company produces a commercial cleaning compound known as Zoom. The direct materials and direct labor standards for one unit of Zoom are given below: Direct materials Direct labor Standard...
-
1. What is importing and exporting and why do countries trade? Importing is buying products from another country and exporting is the opposite, which is selling products to another country. Think of...
-
Two questions to be answered. 2. A tertiary consumer, such as a red-tailed hawk, receives what percent of the energy fixed by primary producers in a typical field ecosystem? 3. Assuming a 10% trophic...
-
A shark which is a fish and a Cetacea (dolphin and porpoise)which is a mammal. Both species have evolved to live in anaquatic environment. However, if you look closely at theirtails, there is a...
-
A 300-mm-long, solid, straight shaft is supported in self-aligning bearings at each end. A gear is attached at the middle of the shaft with a 10-mm square steel key in a slot. The geometric stress....
-
What is removed during each of the three stages of wastewater treatment: primary, secondary, and tertiary? During which state would you expect items to be recovered that were accidentally flushed,...
-
Define the variables x and y as x = 5.1 and y = 4.2, then evaluate: (a) 3/4 xy 7x/y2 + xy (b) (xy)2- x + y/(x-y)l2 + x + y/2x - y
-
The concentration of a drug in the body CP can be modeled by the equation: Cp = DG/Vd (ka/ke ka)(eket eket) where DG is the dosage administered (mg), Vd is the volume of distribution (L), ka is the...
-
Write a user-defined MATLAB function that converts speed given in units of knots (one knot is one nautical mile per hour) to speed in units of feet per second. For the function name and arguments,...
-
Figure P18-39 shows two similar unit pulse waveforms. The only difference is that the first pulse is positive from \(-T / 2\) to \(T / 2\), while the second pulse goes from \(+\mathrm{A}\) to...
-
Describe the principal types of audits performed by independent auditors and indicate the established criteria and primary users of each tyr
-
Contrast the activities of independent, internal, and governmental auditors.
Study smarter with the SolutionInn App