Question: Q 2 9 . [ 1 0 Marks ] Write a Java program to numerically calculate the value of ' x to the power y
Q Marks Write a Java program to numerically calculate the value of to the power
y: WITHOUT using the Math.pow method. No mark will be awarded if
Math.pow method is used to solve this problem.
Program requirements:
a Prompt the user to enter the value The variable should be able to accommodate any
real number. No validation is required.
b Prompt the user to enter the value of You can assume that the user will enter any integer
value positive or negative including zero. No validation is required. Note: your code
should be able to print if the user enters zero for the variable y
c Call a method myPower from the main method to Calculate which will return the
value, and then print the result from the main method. The header of the myPower
method is: public static double myMethoddouble int ;
d After displaying the result of this calculation, the program should ask the user whether she
wants to continue or not. If the user types y or Y as herhis choice, the above steps will be
repeated otherwise the code will be terminated.
Sample output:
Enter value:
Enter value:
The result is:
More power calculation? press to terminate:
Enter value:
Enter value:
The result is:
More power calculation? press to terminate:
Enter value:
Enter value:
The result is:
More power calculation? press to terminate:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
