/*
 * Created on Aug 3, 2005
 * 
 * CPS 006 - Summer 05
 * Sam Slee
 * LinearSearch.java
 * 
 * 
 */

import cs1.Keyboard;

public class LinearSearch {

	public static void main(String[] args) {
		int[] input = {4, 5, 23, 36, 44, 101, 12, 19, 156, 77, 81, 2, 81};
		int goal = 0;
		
		System.out.println("Array entries: ");
		for(int i=0; i<input.length; i++)
			System.out.print(input[i]+" ");
		
		System.out.print("\n\nEnter a number to search for: ");
		goal = Keyboard.readInt();
		
		boolean inArray = linearSearch(input, goal);
		
		System.out.println("\nWas the entry found: "+inArray);
	}
	
	
	public static boolean linearSearch(int[] input, int goal){
		boolean found = false;
		
		for(int i=0; i<input.length; i++){
			if(input[i] == goal)
				found = true;
		}
		
		return found;
	}
}
