public class WhileLoops {
    public static void main(String[] args) {

        // count from 1 to 10:
        int i = 1;
        while (i <= 10) {
            System.out.println(i);
            i++; // i = i + 1
        }
        System.out.println("finally: " + i);

        // count from 10 down to 1:
        int countDown = 10; // initialization
        while (i > 0) { // loop test
            System.out.println(countDown);
            countDown--; // same as countDown = countDown - 1;
        }
        System.out.println("Blastoff");

        // add up all numbers from 1 to 10:
        int sum = 0;
        int k = 1;
        while (k <= 10) {
            sum += k;
            k++;
        }
        System.out.println(sum);

        // add up all numbers from 1 to 10:
        // WHY NOT THIS WAY??
        // int k = 1;
        // while (k <= 10) {
        // int sum = 0;
        // sum += k;
        // k++;
        // }
        // System.out.println(sum);
    }
}