/**
 * A simple program that prints all of the powers of two from 0 up to
 * and including 32. After this is done, it prints 32 as a power of two.
 */
public class PowerOfTwo {
	/**
	 * A field that represent a power of two.
	 */
	protected static int powerOfTwo = 1;
	
	/**
	 * The main method.
	 */
	public static void main(String[] args) {
		
		//a counter that will give us the exponent of the power of two.
		int i = 0;
		
		//a loop to display the power of two.
		while (powerOfTwo < 32) {
			//print which power of two we are currently at.
			System.out.println("The current power of 2 is " + powerOfTwo);
			//compute the next power of two.
			powerOfTwo = getNextPower(powerOfTwo);
			//update the exponent
			i++;
		}
		System.out.println("2^" + i + " = " + powerOfTwo);
	}
	
	
	/**
	 * Given that <code>currentPower</code> is a power of two,
	 * <code>getNextPower(int)</code> returns the next power of two after
	 * <code>currentPower</code>.
	 * @param currentPower a power of two.
	 * @return the next power of two after <code>currentPower</code>.
	 */
	protected static int getNextPower(int currentPower) {
		return currentPower + 2;
	}
		
}
