Write a program Powers.java
that stores a numeric value in the double
variable n
and then displays the square, cube, and fourth power of n
. Use the Math.pow
method to calculate the fourth power.
Sample output:
The number is 3.5
3.5 squared = 12.25
3.5 cubed = 42.875
3.5 to the fourth = 150.0625