Question
Java Programming: Write a program that allows the user to compute the power of a number or the product of two numbers. Your program should
Java Programming:
Write a program that allows the user to compute the power of a number or the product of two numbers.
Your program should prompt the user for the following information:
Type of operation to perform
Two numbers (the arguments) for the operation to perform
The program then outputs the following information:
The result of the mathematical operation selected.
Menu to be displayed for the user:
MATH TOOL
1. Compute the power of a number
2. Compute the product of two numbers
Note: The user will enter the menu number corresponding to the mathematical operation desired, and NOT the type of operation text. For example, if the user wants to compute the power of a number, he/she would type 1 (not Compute the power of a number).
In addition to the main method, your program MUST contain three user-defined methods as follows:
1. Compute the power of a number
2. Compute the product of two numbers
3. Print the formatted result of the mathematical operation
When you write each of your methods, be sure to think about the following:
What information does the main method need to provide to this method in order for it to work properly? For example, in order to calculate the power of a number, what information does the method need from main?
What information does main expect to receive, if any, after this method executes? For example, when calculating the power of a number, what information does main expect to receive back from the method?
Do NOT use any method already defined in Java such as Math.pow, Math.max, etc. You MUST store any calculations in variables (i.e. do not perform calculations directly in your System.out.println statements) You do NOT need to worry about formatting the decimal places on values you calculate You may include additional methods if you want, but you MUST include at least these three methods (plus main).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started