import java.util.Scanner;
import java.util.Random;

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

		//Write a while loop that sums the numbers 2, 4, 6, 8, …, 100.

		int sum = 0;
		int i = 2;
		while(i <= 100) { 
			sum += i;
			i+=2; 
		}
		System.out.println("sum: " + sum);

		//Write a while loop that counts the number of integers between 
		// 1 and 100 that are divisible by 3.

		int count = 0;
		i = 1;
		while(i <= 100) {
			if (i % 3 == 0) {
				count++;
			}
			i++;
		}		
		System.out.println("Count: " + count);


		// Write a fragment of code that has an infinite-loop. Within 
		// the loop, the program asks the user to enter an integer then 
		// reads in the integer.   If the value of the number read is 0, 			// the program exits the loop, otherwise the program continues 
		// in the loop and prints hello.

		Scanner kb = new Scanner(System.in);
		while(true){
			System.out.println("Please enter an integer");
			int x=kb.nextInt();
			if(x==0){
				break;
			}
			System.out.println("Hello");
		}

		// Write a while loop that adds the first 30 numbers of the 
		// Fibonacci sequence: {0, 1, 1, 2, 3, 5, 8, 13, 21, …}.

		int counter = 2;
		int x = 0;
		int y = 1;
		sum = 1;

		while(counter < 5) {
			int next = x + y;
			sum += next;
			counter++;
			x = y;
			y = next;	
		}
		System.out.println("sum: " + sum);

		// Declare an array named arr1 that contains 10 random integers
		// between 1 and 100

		Random rand = new Random();
		int[] arr1 = new int[10];
		for(i = 0; i < 10; i++) {
			arr1[i] = rand.nextInt(99) + 1;
		}
		
		// Print out elements in the arr1

		for(int elm : arr1) {
			System.out.print(elm + " ");
		}
		System.out.println();

		


	}

}
