Problem Definition Write a Python program that calculates the perimeter and area of multiple simple geometrical shapes based on the user's selection. Let the program handle the perimeter and area calculations for circle, rectangle and parallelogram shapes. The program should display a menu of the three shapes, and then allow the user to select one of the options. Accordingly, the program would request from the user to enter the required parameters of the corresponding geometrical shape in floating- point form (e.g., radius of a circle, or the width and length of a rectangle). When you finish a shape prompt the user to see if there are more shapes to process. The program should: interact with the user in a friendly way using a menu listing the different shapes (C: Circle, R: Rectangle, P: Parallelogram). • display an error message for invalid shape options for a parallelogram, keep asking the user until a valid angle (within 0 and 180 degrees) is entered. compute the perimeter and the area for the selected shape using the following table. Circle Rectangle Parallelogram Parameters Radius r Width w Sides Sl and S2 Length h Angle a Perimeter 2 πr 2(w + h) 2(S1 + S2) 0 < a st/2: (SI*S2)sina T/2 < as n: (S1*S2)sin(r-a) Area w.h for output, display the values for perimeters using one decimal place and the values for the areas using 3 decimal places as shown in the sample run. Figures 1(a) – 1(f) illustrate sample runs of the program. Select one of the followáng geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Enter your choice (C, R or P): c ***** Enter the radius of the Circle: 7 Enter your choice (C, R or P): t Shape Perimeter Area ERROR> Invalid choice: 't' Circle 44.e 153.938 Enter anether shap: (Y/N)? y .... Enter another shape (Y/N)? n Figurel (a): Invalid choice Figurel (b): Circle choice Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Enter your choice (C,R or P): P Enter your choice (C, R or P): r Enter sidel of the parallelogram: 6 Enter the length of the rectangle: 5.5 Enter side2 of the parallelogram: 7 Enter the width of the rectangle: 6.25 Enter the angle between the sides (in degrees): 60 Shape Perimeter Area Shape Perimeter Area ... Rectangle 23.5 34.375 Parallelogram 26.0 36.3 ******.... Enter another shape (Y/N)? n Enter another shape (Y/N)?N Figurel (d): Parallelogram choice, angle:60 Figurel (c): Rectangle choice Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Enter your choice (C, R or P):P Enter your choice (C, R or P): p Enter sidel of the parallelogram: 3 Enter sidel of the parallelogram: 3 Enter side2 of the parallelogram: 6 Enter the angle between the sides (in degrees): -1 ERROR> angle value: -1.0 is outside range (e.1801. Enter side2 of the parallelogram: 6 Enter the angle between the sides (in degrees): 60 Enter the angle between the sides (in degrees): 100 Shape Perimeter Area Shape Perimeter Area 18.e Parallelogram 15.588 Parallelogram 18.0 17.727 Enter another shape (Y/N)?n Enter another shape (Y/N)? Y Figurel (f): Parallelogram choice, angle:-1; keep asking the user until valid angle Figurel (e): Parallelogram choice, angle:100 our program should:
Problem Definition Write a Python program that calculates the perimeter and area of multiple simple geometrical shapes based on the user's selection. Let the program handle the perimeter and area calculations for circle, rectangle and parallelogram shapes. The program should display a menu of the three shapes, and then allow the user to select one of the options. Accordingly, the program would request from the user to enter the required parameters of the corresponding geometrical shape in floating- point form (e.g., radius of a circle, or the width and length of a rectangle). When you finish a shape prompt the user to see if there are more shapes to process. The program should: interact with the user in a friendly way using a menu listing the different shapes (C: Circle, R: Rectangle, P: Parallelogram). • display an error message for invalid shape options for a parallelogram, keep asking the user until a valid angle (within 0 and 180 degrees) is entered. compute the perimeter and the area for the selected shape using the following table. Circle Rectangle Parallelogram Parameters Radius r Width w Sides Sl and S2 Length h Angle a Perimeter 2 πr 2(w + h) 2(S1 + S2) 0 < a st/2: (SI*S2)sina T/2 < as n: (S1*S2)sin(r-a) Area w.h for output, display the values for perimeters using one decimal place and the values for the areas using 3 decimal places as shown in the sample run. Figures 1(a) – 1(f) illustrate sample runs of the program. Select one of the followáng geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Enter your choice (C, R or P): c ***** Enter the radius of the Circle: 7 Enter your choice (C, R or P): t Shape Perimeter Area ERROR> Invalid choice: 't' Circle 44.e 153.938 Enter anether shap: (Y/N)? y .... Enter another shape (Y/N)? n Figurel (a): Invalid choice Figurel (b): Circle choice Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Enter your choice (C,R or P): P Enter your choice (C, R or P): r Enter sidel of the parallelogram: 6 Enter the length of the rectangle: 5.5 Enter side2 of the parallelogram: 7 Enter the width of the rectangle: 6.25 Enter the angle between the sides (in degrees): 60 Shape Perimeter Area Shape Perimeter Area ... Rectangle 23.5 34.375 Parallelogram 26.0 36.3 ******.... Enter another shape (Y/N)? n Enter another shape (Y/N)?N Figurel (d): Parallelogram choice, angle:60 Figurel (c): Rectangle choice Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Select one of the following geometrical shapes: C: circle. R: Rectangle. P: parallelogram. Enter your choice (C, R or P):P Enter your choice (C, R or P): p Enter sidel of the parallelogram: 3 Enter sidel of the parallelogram: 3 Enter side2 of the parallelogram: 6 Enter the angle between the sides (in degrees): -1 ERROR> angle value: -1.0 is outside range (e.1801. Enter side2 of the parallelogram: 6 Enter the angle between the sides (in degrees): 60 Enter the angle between the sides (in degrees): 100 Shape Perimeter Area Shape Perimeter Area 18.e Parallelogram 15.588 Parallelogram 18.0 17.727 Enter another shape (Y/N)?n Enter another shape (Y/N)? Y Figurel (f): Parallelogram choice, angle:-1; keep asking the user until valid angle Figurel (e): Parallelogram choice, angle:100 our program should:
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.1: Function And Parameter Declarations
Problem 11E
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 5 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr