Using switch statements, build a Java class file to calculate the area of a figure (call it Area.java). The figure may be a circle or a square or a rectangle. The user will enter the type of figure they want through a Scanner object. It they enter “Circle”, proceed to calculate the area of a Circle using values your request for radius. If they enter an “Square”, then calculate the area of the circle using values you request for side. If they enter an “Radius”, then calculate using values you request for height and width.
Using switch statements, build a Java class file to calculate the area of a figure (call it Area.java). The figure may be a
circle or a square
or a rectangle. The user will enter the type of figure they want through a Scanner object. It they
enter “Circle”,
proceed to calculate the area of a Circle using values your request for radius. If they enter an
“Square”, then
calculate the area of the circle using values you request for side. If they enter an “Radius”, then
calculate using
values you request for height and width.
logic:-
read user’s choice.
Pass user’s choice within switch
define three cases circle, square and rectangle
Read radius for circle, side for square , and height and width for rectangle.
Write area formula for each case.
Display area.
End.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images