This lab is designed to reinforce your understanding of (static) methods and to help you develop an understnanding of the "switch" statement.
This assignment comes in two parts. The first part is to write several static functions. The second part is to write a main() method that uses a swich statment driven menu to expose this functionality.
Please implement the following static functions (assume that all user input is non-negative):
- public static long pow (long x, long n)
- Computes xn
- public static long fact(long n)
- Computes n!
- public static double circleArea(double radius)
- Computes area = PI * radius * radius, PI=3.14159265
- public static double rectangleArea(double length, double width)
- Computes area=length*width
The main method should provide the user with the following menu, take the action requested by the user, and repeat, until the user chooses to exit. The menu processing should be case-insensitive.
--- Menu --- P)ower F)actorial C)ircle R)ectangle Q)uit
After selecting an option, the user should be prompted for the necessary number, the computation should be preformed, and the user should be presented with the results.
In order to maintain code reabaility, you should implement the following helper methods:
- private static int getIntFromUser (String prompt)
- private static double getDoubleFromUser (String prompt)
Please do take time to make your programs "pretty". Make the prompts informative and the results understandable. Make the menu present itself well, using empty lines, &c, as needed.