someone pliz help have written this program but it does not display 2 to that power instead it asks to enter a power and when -1 is entered the program ends m missing out on something if someone could help then
import java.io.*;
class power
{
public static void main(String[] args)throws IOException
{
int count = 0;
int power;
int exponent = 2;
double result = 1;
BufferedReader Keyboard=new BufferedReader( new
InputStreamRead er(System.in));
power = Integer.parseIn t(Keyboard.read Line());
while (count < exponent)
{
result = result * 2;
count = count +1;
}
}
}
import java.io.*;
class power
{
public static void main(String[] args)throws IOException
{
int count = 0;
int power;
int exponent = 2;
double result = 1;
BufferedReader Keyboard=new BufferedReader( new
InputStreamRead er(System.in));
power = Integer.parseIn t(Keyboard.read Line());
while (count < exponent)
{
result = result * 2;
count = count +1;
}
}
}
Comment