Create a menu-driven program that calculates the area of a few, basic geometric shapes. The program begins by displaying the menu to the user. The user has four choices to select from:

1. Calculate the area of a circle.
2. Calculate the area of a rectangle.
3. Calculate the area of a triangle
4. Exit the program

After displaying the menu, the program gets the user's choice and performs the desired action. The program then starts over at the menu, allowing the user to choose again. The program stops when the user finally enters option 4.

Respuesta :

Answer:

todo = True

[tex]print("Menu\n\ 1 - Area\ of\ Circle\n\ 2 - Area\ of\ Rectangle\n\ 3 - Area\ of Triangle\n\ 4 - Exit")[/tex]

menu = int(input("Select Menu: "))

while(todo):

   if menu == 1:

       radius = float(input("Radius: "))

       print("Area: "+str(3.142 * radius * radius))

       todo = True

       menu = int(input("Select Menu: "))

   elif menu == 2:

       length = float(input("Length: "))

       width = float(input("Width: "))

       print("Area: "+str(length * width))

       todo = True

       menu = int(input("Select Menu: "))

   elif menu == 3:

       bs = float(input("Base: "))

       hght = float(input("Height: "))

       print("Area: "+str(bs * hght/2))

       todo = True

       menu = int(input("Select Menu: "))

   elif menu == 4:

       todo = False

   else:

       print("Invalid menu selected")

       todo = True

       menu = int(input("Select Menu: "))

Explanation:

The program was written in Python and the explanation goes thus:

See attachment for explanation where I used comment to explain the program

Ver imagen MrRoyal
ACCESS MORE