Write a method power(double a , int n) that calculates and displays the result of the double parameter a raised to the power n. For example
power(3.0 , 2); display 3 to the power 2=9 power(2.0 , 3); display 2 to the power 3=8
OK, you need to add a method power(double a, int n) with the given behaviour. Seems straight forward so far.
You don't say what the second of the two methods is.
Think about these steps:
1. Write an empty class called Power 2. Add a method power(double a, int n) which works out a[SUP]n[SUP] and prints out a line "a to the power n = ?", where you replace a, n and ? with the correct values. 3. Add second method, whatever that is. 4. Write a method
and in the method body, call your two new methods with some test data.