Write java program to do the following:
Write a METHOD to input an array of type LONG that stores the value
of all the powers of 2 from 0 to 63 (i.e. 2^0
to 2^63
)
Output the contents of the array screen (what happens if you try 2^64
?)
Hint: Math.pow(x,y) is used to put number x to exponent y
Program just outputs 1.0 many times which isn't right can anyone help
public class W3P3{
public static void main(String[]args){
double [] myArray = new double [63];
long myEntry=0;
long Myarray=0;
power(myEntry,Myarray);
}//end of main
//Method
public static void power(long x,long y){
double results=0;
for (int i = 2; i <= 63; i++)
{
results = Math.pow(x,y);
System.out.println("The result of powers is "+ results);
}
}//end of method
}//end of class