import java.util.Scanner;

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

		Scanner kb = new Scanner(System.in);

		int[] scores = new int[10];

		printArray(scores); // calling the method

		// set all elements to -1
		for(int i = 0; i < scores.length; i++) {
			scores[i] = -1;
		}

		printArray(scores);

		System.out.println("Enter an index");
		int index = kb.nextInt();

		// check to be sure index is valid
		if (index < 0 || index >= scores.length) {
			System.out.println("Invalid index");
		}
		else {
			System.out.println("Enter value");
			int value = kb.nextInt();
			scores[index] = value;
			printArray(scores);
		}
		
		// set the elements to random values

		for(int i = 0; i < scores.length; i++) {
			scores[i] = (int) (Math.random() * 100);
		}
		printArray(scores);

		// compute the sum of the elements in the array
		int sum = 0;
		for(int i = 0; i < scores.length; i++) {
			sum += scores[i];
		}
		System.out.println("sum: " + sum);

		// fill array with values entered by user
		System.out.println("Enter 10 integers with spaces between them");
		for(int i = 0; i < scores.length; i++) {
			scores[i] = kb.nextInt();
		}
		printArray(scores);

	}

	static void printArray(int[] arr) {

		// print to the screen elements in the array
		for(int i = 0; i < arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
		System.out.println();
	} 
}
