Answer to Question #202878 in Algorithms for Marie

Question #202878

Design an algorithm to read a value from the keyboard which represents the name of a shape. Allowed shapes are circle, square, and triangle, any other shape name should result in an error message being displayed. For each shape the area of the is to be calculated and displayed so the program should prompt the user for any additional information needed to calculate the area based on the shape. For triangles, only right-angled triangles are allowed. The calculated area along with the input from the user should be displayed.


Draw the flowchart and write the pseudocode for the algorithm.


1
Expert's answer
2021-06-04T07:41:47-0400

Input: "Enter Shape" //prompt the user

if Shape = Circle then

Input: "Enter R" // radius of circle

S = "\\pi R^2" // circle area

if Shape = Square then

Input: "Enter a" // side of square

S = "a^2" // square area

if Shape = right-angled Triangle then

Input: "Enter a, b" // sides of triangle

S = ab/2 // triangle area

else

Error

Output:

Shape, S



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS