The first 11 powers of ten, beginning with exponent 0, are:
1.0
10.0
100.0
1000.0
10000.0
100000.0
1.0E7
1.0E8
1.0E9
1.0E10
1.0E11
Write a class PowerGenerator
that will create powers of any given factor. The constructor for this class will establish the factor (10
in the example above), and the nextPower()
method, each time it is called, returns the next successive power.
Sample use in a program:
PowerGenerator pg = new PowerGenerator(2);
System.out.println(pg.nextPower()); --> 1
System.out.println(pg.nextPower()); --> 2
System.out.println(pg.nextPower()); --> 4
Write a test class PowerGeneratorRunner
that constructs a PowerGenerator and then calls
System.out.println(myGenerator.nextPower())
twelve times.