Hey guys! So I'm writing a code that takes 10 numbers from the user which is stored in a array. The user then inputs the problem number (1 or 2) depending on what they want to do to the array. Unfortunately, I'm getting and error on line array[i].prob1();
.. Here's what I have:
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int[] array = new int[10];
System.out.println("Enter 10 numbers: ");
for(int i = 0; i < array.length; i++){
int num = s.nextInt();
array[i] = num;
}
System.out.print("Enter problem number 1 or 2: ");
int probNum = s.nextInt();
if (probNum == 1){
array[i].prob1();
}
}
public static int prob1 (int[] array){
for (int i = 0; i < array[i]; i++){
if (array[i] % 2 != 0)
{
System.out.print(array[i]);
}
}
return array[1];
}
}
Thanks guys!