Question

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 - 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 the rectangle and then display the rectangle's area.
  • 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.
  • If the user enters 4, the program should end.

Input Validation:

  • Do not accept values outside the range of 1 and 4 when selecting from the menu.
  • Do not accept negative or less than 0 values for any input amounts (ie. radius, length, width, etc).

Can anybody help me with this? I want to get a Psuedocode for the problem and the Program code for this.

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

def ch(a):
if a == 1:
r= float(input('Enter the radius:'))
area =3.14*r*r
print('The area of the circle is %0.2f' %area)
elif a == 2:
l= float(input('Enter the length:'))
b= float(input('Enter the breadth:'))
area =l*b
print('The area of the rectangle is %0.2f' %area)
elif a == 3:
h= float(input('Enter the height:'))
b= float(input('Enter the base:'))
area =0.5*h*b
print('The area of the triangle is %0.2f' %area)
else:
print (exit)

print('Geometry Calculator \n')
print('1 Calculate the Area of Circle \n')
print('2 Calculate the Area of Rectangle \n')
print('3 Calculate the Area of Triangle \n')
print('4 Quit\n')
a= int(input('Enter your Choice:'))
ch(a)

Add a comment
Know the answer?
Add Answer to:
Problem: Given information about a circle, rectangle and a triangle, calculate the area of the shape...
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...

  • 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...

  • 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...

  • 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...

  • Write a Java application to find the area of 1) rectangle 2) Triangle 3) Circle using...

    Write a Java application to find the area of 1) rectangle 2) Triangle 3) Circle using runtime polymorphism concept. Shape Area rectangle length*width Triangle 0.5*length*width Circle PI*radius*radius. I am confused as to what polymorphism is and would really appreciate some help. This is in Java as well.

  • Question 4 Write a program that display the area of a triangle. The program calls the...

    Question 4 Write a program that display the area of a triangle. The program calls the following two functions: .getBaseHeight - This function uses a reference parameter variables to accept a double arguments base and height. This function should ask the user to enter the triangle's buse and height. Input validation: base and height should be positive numbers. calArea - This function should accept the triangle's base and height as arguments and return the triangle's area. The area is calculated...

  • java language Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectang...

    java language Problem 3: Shape (10 points) (Software Design) Create an abstract class that represents a Shape and contains abstract method: area and perimeter. Create concrete classes: Circle, Rectangle, Triangle which extend the Shape class and implements the abstract methods. A circle has a radius, a rectangle has width and height, and a triangle has three sides. Software Architecture: The Shape class is the abstract super class and must be instantiated by one of its concrete subclasses: Circle, Rectangle, or...

  • C++ program. int main() {    Rectangle box;     // Define an instance of the Rectangle class...

    C++ program. int main() {    Rectangle box;     // Define an instance of the Rectangle class    double rectWidth; // Local variable for width    double rectLength; // Local variable for length    string rectColor;    // Get the rectangle's width and length from the user.    cout << "This program will calculate the area of a\n";    cout << "rectangle. What is the width? ";    cin >> rectWidth;    cout << "What is the length? ";    cin >>...

  • 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...

  • 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...

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