Question: JAVA ONLY please. The part in bold is what needs to be replaced. We are switching from Long to BigInteger to raise 50 to the
JAVA ONLY please. The part in bold is what needs to be replaced. We are switching from Long to BigInteger to raise 50 to the power of 70.
Assume that we want to calculate the result of raising 50 to the power of 70. Power.java calculates the power function of n raised to the power of m:
import java.math.BigInteger; public class Power { public static void main(String[] args) { System.out.println("50 raised to the power of 70 is " + power(50,70)); }
public static Long power(long m,long n) { long result = 1; for (int i = 1; i <= n; i++) result = result*m; return result; } }
Design a LargePower class that will replace the above code(the part in bold) to calculate 50 raised to the power of 70 using BigInteger instead of Long.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
