rendered paste body//Alexander Clark
//2/17/08
//CH7 7.12 ... what the hell is that...have you seen that before? yeah, its h it happens when i tried to run it last time.
import java.util.Scanner;
public class Duplicate
{
int number = 0;
public static int arraycheck = -1;
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int counter = 0;
int testValue = 0;
int array[] = new int[5];
for(counter = 0; counter < array.length;)
{
System.out.print("Enter an integer between 10 and 100: ");
testValue = input.nextInt();
if(testValue >= 10 && testValue <= 100)
{
if(checkArray(array, array[counter])==false)
{
System.out.println("Duplicate, try again.");
}
else
{
array[counter] = testValue;
System.out.println("");
System.out.println("Index 0: " + array[0]);
System.out.println("Index 1: " + array[1]);
System.out.println("Index 2: " + array[2]);
System.out.println("Index 3: " + array[3]);
System.out.println("Index 4: " + array[4]);
System.out.println("");
counter++;
}
}
else
{
System.out.println("ERROR");
}
}
}
public static boolean checkArray(int array[], int number)
{
arraycheck ++;
if(arraycheck != 0);
{
for(int counter = 0; counter <= array.length-(5-arraycheck); counter++)
{
if(number == array[counter])
{
return true;
}
}
}
return false;
}
}