Question: Complete programming in python exercise 3 on page 5 9 2 ( 5 th edition ) in the text. Modularize your code using procedures, as

Complete programming in python exercise 3 on page 592(5th edition) in the text. Modularize your code using procedures, as discussed in section 11.2. Use a loop to
repeat the menu, as discussed in section 11.3. Validate the menu entry. Use the built in constant in the Math library for Pi (instead of putting the literal value
in your code).
Use defensive programming for this assignment. Your program should give the user an error and allow them to re-enter if they enter an unreasonable value
(for example, a zero or negative radius for a circle, or an invalid menu choice). You may assume that the user will enter either an integer or floating-point
number, as appropriate.
Half of your grade for this assignment will be for defensive programming. If you chose to complete this optional assignment make sure you implement all the
required defensive programming.
Geometry Calculator
Write a program that displays the following menu:
Geometry Calculator
Calculate the Area of a Circle
Calculate the Area of a Rectangle
Calculate the Area of a Triangle
Quit
Enter your choice (1-4).
If the user enters 1, the program should ask for the radius of the circle and then
display its area. Use the following formula to calculate the circle's area:
" area "=pir^(2)
Use 3.14159 for pi and the radius of the circle for r.
If the user enters 2, the program should ask for the length and width of the rectan-
gle, and then display the rectangle's area. Use the following formula to calculate
the rectangle's area:
" area "=" length "xx" width "
If the user enters 3, the program should ask for the length of the triangle's base and
its height, and then display its area. Use the following formula to calculate the area
of the triangle:
" area "=" base "xx" beight "xx.5
If the user enters 4, the program should end. ** James Shoe **
1. Calculate the area of a Circle
2. Calculate the area of a Rectangle
3. Calculate the area of a Triangle
4. Quit
Enter your choice (1-4): 5
ERROR: Enter a valid number between 1 and 4
Enter your choice (1-4): 0
ERROR: Enter a valid number between 1 and 4
Enter your choice (1-4): 1
---Area for a Circle---
Enter the radius: -5
ERROR: The radius of a circle must be greater than zero.
Please re-enter the radius: 0
ERROR: The radius of a circle must be greater than zero.
Please re-enter the radius: 10
The answer is: 314.1592653589793
1. Calculate the area of a Circle
2. Calculate the area of a Rectangle
3. Calculate the area of a Triangle
4. Quit
Enter your choice (1-4): 4** James Shoe **
1. Calculate the area of a Circle
2. Calculate the area of a Rectangle
3. Calculate the area of a Triangle
4. Quit
Enter your choice (1-4): 5
ERROR: Enter a valid number between 1 and 4
Enter your choice (1-4): 0
ERROR: Enter a valid number between 1 and 4
Enter your choice (1-4): 1
---Area for a Circle---
Enter the radius: -5
ERROR: The radius of a circle must be greater than zero.
Please re-enter the radius: 0
ERROR: The radius of a circle must be greater than zero.
Please re-enter the radius: 10
The answer is: 314.1592653589793
1. Calculate the area of a Circle
2. Calculate the area of a Rectangle
3. Calculate the area of a Triangle
4. Quit
Enter your choice (1-4): 4
Complete programming in python exercise 3 on page

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!