
public class LoopIntro {

	public static void main(String[] args) {
		//loops: repetition
		// 1. Where do we start? 
		// 2. Where do we stop?
		// 3. How do we move?
		// 4. What do we repeat?
		
		// while loop
		//repeat something 10 times
		
		// 1. starting point
		int count = 1;
		
		// 2. condition between () - true to keep going
		while (count <= 5) { 
			// 4. repeat
			System.out.println("something");
			
			// 3. next move
			count = count + 1;
		}
		
		//print out count's value
		count = 1;  //1.
		
		while(count <= 10) { //2
			// %3d - 3 is the field width
			System.out.printf("%3d", count); //4
			++count; //3
		}
		System.out.println();
		
		//print from 10 to 20 each on a line
		count = 10;  //1
		
		while(count <= 20) {  //2
			System.out.println(count);  //4
			count += 1; // 3
		}
		
		//count from 1 to 20 by 2
		count = 1;
		
		while(count <= 20 ) {
			System.out.println(count);
			count += 2;
		}
		
		//count from 10 down to 1
		count = 10;
		
		while(count >= 1 ) {
			System.out.println(count);
			count -= 1;
		}
		
		//calculate the sum of integers 1 to 1000
		count = 1;
		int sum = 0;
		while(count <= 1000) {
			sum = sum + count;
			count++;
		}
		System.out.println(sum);
		
		//print 0, 0.1, 0.2, 0.3, 0.4 ... 1.0
		double x = 0;
		
		while( x <= 1.0) {
			System.out.printf("%f\t", x);
			System.out.println(x);
			x += 0.1;
		}
		
		System.out.println("Done");
		
	}

}
