Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 9 Weeks Ago, 3 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Write a Java program that will display the following menu until the exit choice (#4) is selected by the user (See Sample Program Run below). The program will calculate the areas and perimeter or circumference by calling only two functions and passing two parameters: a numeric value (side), and a character code to each function.
Program Requirements:
1.The character code, ‘C’ or ‘S’, is used to distinguish between circle and square shapes.
2.  calcArea() will accepttwo parametersand return the area of the shape (either the circle or the square depending on the character code received).
3.calcPerim()will accepttwo parametersand return the perimeter or circumference of the shape (either the circle or the square depending on the character code received).
4.Themain()functionwill display a message which identifies the selected shape and its area or perimeter/circumference, depending upon the selected option.
5.PIshould be declared as a constant.
Â
--------------------------------------------------------------------------------------------------------------------------
Sample Program Run: (USER INPUT appears in BOLD and RED.)
Â
Geometric Calculator
Choose one of the following options:
Â
Press 1 to enter the side or radius and shape code.
Press 2 to display the area.
Press 3 to display the perimeter or circumference.
Press 4 to exit.
Enter selection: Â 1
Please enter a value for radius or side:10.0
Please enter the shape code (c/C for circle, s/S for square):Â s
Press 1 to enter the side or radius and shape code.
Press 2 to display the area.
Press 3 to display the perimeter or circumference.
Press 4 to exit.
Enter selection: Â 2
The area of a square with a side of 10 is: 100.00
Press 1 to enter the side or radius and shape code.
Press 2 to display the area.
Press 3 to display the perimeter or circumference.
Press 4 to exit.
... (More testing must be included here)
Enter selection: Â 4
Thank you for using the geometric calculator. Bye!