Question

Geometric calclator use python to do this program. Write a program that displays the following menu:...

Geometric calclator use python to do this program.

Write a program that displays the following menu:

1. Calculate the area of circle

2. calculate the area of rectangle

3. calculate the area of triangle

4. Quit

Enter your choice (1-4).

if the user enters 1, your program should ask for the radius of the circle and then display its area. Use the formula to calculate the circle's area:

Area = pi*r^2

Use 3.14149 for Pi and the radius of the circle for r.

if user enters 2, the program should ask for the length and width of the rectangle and then display the rectangle's area. use the following formula to calculate rectangle's area.

area = length * width

if user enters 3, the program should ask for the length of the triangle base and its height, and, then display it's area. use the following formula to calculate the area of the triangle.

area = base * height * .5

if the user enters 4, the program should end.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import math
def rectangleArea (width, length):
return width*length
def circleArea(radius):
return math.pi*math.pow(radius,2)
def triangleArea (base, height):
return (base*height)/2
print("Enter your choice:")
print("1. Calculate the area of circle\n2. calculate the area of rectangle")
print("3. calculate the area of triangle\n4. Quit")
n=int(input("Enter choice: "))
if(n==1):
radius=float(input("circle radius: "))
print("Circle area: ",circleArea(radius))
elif(n==2):
width=float(input("Rectangle width: "))
lenght=float(input("Rectangle lenght: "))
print("Rectengle Area: ",rectangleArea(width,lenght))
elif(n==3):
base=float(input("triangle base: "))
height=float(input("triangle height: "))
print("Circle area: ",triangleArea(base,height))
elif(n==4):
exit
else:
print("Invalid input")

import math def rectangleArea (width, length): return width*length return math.pi*math.pow(radius,2) return (base*height)/2 def circleArea(radius): def triangleArea (base, height): print(Enter your choice:) print(1. Calculate the area of circle n2. calculate the area of rectangle) print(3. calculate the area of triangleln4. Quit) n-int (input (Enter choice: )) if(n-1): CUsers rishirajAppData\Local\Programs Python Py radius-float(input (circle radius: print (Circle area: ,circleArea (radius)) Enter your choice: L. Calculate the area of circle elif(n--2): calculate the area of rectangle -calculate the area of triangle Quit width-float (input(Rectangle width: )) lenght-float(input( Rectangle lenght: )) print (Rectengle Area: ,rectangleArea (width,lenght)) Enter choice 1 ircle radius 3 ircle area 28.274333882308138 Process returned 0 (0x0) Press any key to continue .. . execution time : 5 elif(n--3): base-float (input(triangle base: ) height-float(input(triangle height: )) print(Circle area: ,triangleArea (base, height)) elif(n--4): exit else: print(Invalid input)

Add a comment
Know the answer?
Add Answer to:
Geometric calclator use python to do this program. Write a program that displays the following menu:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator...

    (PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator 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): If the user enters 1, the program should ask for the radius of the circle and then display its area. If the user enters 2, the program should ask for the length and width of...

  • Java only please Write a program that displays the following menu: Geometry Calculator 1.       Calculate the...

    Java only please Write a program that displays the following menu: Geometry Calculator 1.       Calculate the Area of a Circle 2.       Calculate the Area of a Triangle 3.     Calculate the Area of a Rectangle 4.       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 formula:      area = ∏r2    Use 3.14159 for ∏. If the user enters 2 the program should ask for...

  • Create a menu-driven program (using the switch) that finds and displays areas of 3 different objects....

    Create a menu-driven program (using the switch) that finds and displays areas of 3 different objects. The menu should have the following 4 choices: 1 -- rectangle 2 -- circle 3 -- triangle 4 -- quit If the user selects choice 1, the program should find the area of a rectangle. rectangle area = length * width If the user selects choice 2, the program should find the area of a circle. circle area = PI * radius * radius...

  • Problem: Given information about a circle, rectangle and a triangle, calculate the area of the shape...

    Problem: Given information about a circle, rectangle and a triangle, calculate the area of the shape from the information supplied. Write pseudocode to solve this problem and write a Python program that asks the user to input the required information for a shape and then calculates the area of the shape. Geometry Calculator 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...

  • Menu-driven programs will display the menu options to the user and then prompt them for a...

    Menu-driven programs will display the menu options to the user and then prompt them for a menu choice. This program will display the following menu in the following format: Calculator Options: Calculate the area of a circle Calculate the area of a rectangle Calculate the area of a triangle Calculate the area of a trapezoid Calculate the area of a sphere Exit Enter your choice (1-6) Once the user enters a choice for the menu, the program should use a...

  • Using C++, Write a program that will provide the user a menu from which the user...

    Using C++, Write a program that will provide the user a menu from which the user may select to calculate the area of one of four geometric shapes: a circle, a rectangle, a triangle, and a trapezoid. You should use the most appropriate SWITCH block for this program. The user will input all data needed to calculate the area. The program should output all data input by the user, the calculated area, and the geometric shape selected. Run this program...

  • 1. Write a program that determines the area and perimeter of a square. Your program should...

    1. Write a program that determines the area and perimeter of a square. Your program should accept the appropriate measurement of the square as input from the user and display the result to the screen. Area of Square = L (squared) Perimeter of Square = 4 * L 2.  Write a program that determines the area and circumference of a circle. Your program should accept the appropriate measurement of the circle as input from the user and display the result to...

  • Using Python Write the following well-documented (commented) program. Create a class called Shape that has a...

    Using Python Write the following well-documented (commented) program. Create a class called Shape that has a method for printing the area and the perimeter. Create three classes (Square, Rectangle, and Circle) which inherit from it. Square will have one instance variable for the length. Rectangle will have two instance variables for the width and height. Circle will have one instance variable for the radius. The three classes will have methods for computing the area and perimeter of its corresponding shape....

  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

    C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...

  • Use Java program Material Covered : Loops & Methods Question 1: Write a program to calculate...

    Use Java program Material Covered : Loops & Methods Question 1: Write a program to calculate rectangle area. Some requirements: 1. User Scanner to collect user input for length & width 2. The formula is area = length * width 3. You must implement methods getLength, getWidth, getArea and displayData ▪ getLength – This method should ask the user to enter the rectangle’s length and then return that value as a double ▪ getWidth – This method should ask the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT