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 on page th edition in the text. Modularize your code using procedures, as discussed in section Use a loop to
repeat the menu, as discussed in section 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 reenter 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 floatingpoint
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
If the user enters 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
Use for pi and the radius of the circle for r
If the user enters 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 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
If the user enters the program should end. James Shoe
Calculate the area of a Circle
Calculate the area of a Rectangle
Calculate the area of a Triangle
Quit
Enter your choice :
ERROR: Enter a valid number between and
Enter your choice :
ERROR: Enter a valid number between and
Enter your choice :
Area for a Circle
Enter the radius:
ERROR: The radius of a circle must be greater than zero.
Please reenter the radius:
ERROR: The radius of a circle must be greater than zero.
Please reenter the radius:
The answer is:
Calculate the area of a Circle
Calculate the area of a Rectangle
Calculate the area of a Triangle
Quit
Enter your choice : James Shoe
Calculate the area of a Circle
Calculate the area of a Rectangle
Calculate the area of a Triangle
Quit
Enter your choice :
ERROR: Enter a valid number between and
Enter your choice :
ERROR: Enter a valid number between and
Enter your choice :
Area for a Circle
Enter the radius:
ERROR: The radius of a circle must be greater than zero.
Please reenter the radius:
ERROR: The radius of a circle must be greater than zero.
Please reenter the radius:
The answer is:
Calculate the area of a Circle
Calculate the area of a Rectangle
Calculate the area of a Triangle
Quit
Enter your choice :
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
