// Arup Guha
// 6/26/06
// Edited by Lisa Soros
// 7/9/10
// BHCSI 2006 Class Example illustrating the use of arrays.
import java.util.*;
public class Arrays2 {
	
	
	public static void main(String[] args) {
		
		// Declare a new array.	
		int[] values = new int[10];
		
		// Fill up all ten values.
		values[0] = 2;
		values[1] = 3;
		for (int i=2; i<values.length; i++)
			values[i] = 2*values[i-1] - values[i-2];	
		
		// Try to print out the whole array. 
		// This actually prints out a memory address; not what you wanted.
		System.out.println(values);
		System.out.println();
		
		// This is the correct way to print all the values in the array.
		for (int i=0; i<values.length; i++)
			System.out.print(values[i]+" ");
		System.out.println();
		System.out.println();
		
		
		// This part of the program reads in several test scores and
		// finds the minimum score.
		Scanner stdin = new Scanner(System.in);
		
		// Read in the number of scores.
		System.out.println("How many scores?");
		int numscores = stdin.nextInt();
		
		// Allocate the array to be the right size.
		int[] scores = new int[numscores];
		
		// Read in each score.
		System.out.println("Enter each score separated by a space.");
		for (int i=0; i<scores.length; i++)
			scores[i] = stdin.nextInt();
			
		// Set the initial min value to be the first one.
		int min = scores[0];
		int minindex = 0;
		
		// Loop through the rest of the values.
		for (int i=1; i<scores.length; i++) {
			
			// If we see a smaller value, update min and minindex.
			if (scores[i] < min) {
				min = scores[i];
				minindex = i;
			}
		}
		
		System.out.println("The smallest value is "+min+" and it is stored in index "+minindex);	            
	}
}