1
10
100
1000
etc...
however my program will display a number 12 times (2.147483647E9 << that number). can anyone spot what im doing wrong?
public class PowerGenerator {
public int power;
public PowerGenerator(int i)
{
power = (int) Math.pow(10,i);
}
public double nextPower() {
return power;
}
}
and my driver is
public class PowerGeneratorRunner {
public static void main(String[] args)
{
PowerGenerator myGenerator = new PowerGenerator(10);
for (int i = 1; i <= 12; i++)
System.out.println(myGenerator.nextPower());
}
}


Sign In
Create Account


Back to top









