Question: Please use explanations for the code. Thank you. Using Scanner for User Input Write a program that asks the user for an integer, then prints
Please use explanations for the code. Thank you.
Using Scanner for User Input
Write a program that asks the user for an integer, then prints the integer, its square, and its cube to the screen.
Try computing the output in two ways:
1) without using Math.pow()
2) using Math.pow()
Use the Java API to learn what parameters Math.pow() requires.
Note: pow() is a static method of the Math class, which means that you do not need a Math object to call it. To call the pow() method, just write Math.pow(), but fill in the appropriate parameters between the ().
Challenge: Change your program to ask the user for two integers. Use Math.pow() to compute xn where x is the first integer the user enters, and n is the second integer the user enters.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
