CS211 Bootcamp Solutions
Step 4
Prepared by:  Alvin Law (ajl56@cornell.edu)

4.3
public class BasicsDemo
{
	public static void main(String[] args)
	{
		int sum = 0;
		for (int current = 10; current >= 1; current--)
		{
			sum += current;
		}
		System.out.println("Sum = " + sum);
	}
}

To add backwards, only the for loop must change.  We start the current counter at 10 instead, and tell it to keep going as long as current >= 1.  We then decrement by 1 instead of increment by 1.  Because addition is communative, the sum displayed is still 55.