so I am a beginner in java. I am trying to create a program that tells me the even ints in the array. However, I keep getting the array out of bounds error:10 at line 29(where I sy "formula[even[b]]. Help please?
public class arrayone
{
public static void main(String args [])
{
/*
tell me the number of even ints in the given array. Note: the % "mod" operator computes the remainder, e.g. 5 % 2 is 1.
*/
//declare an array
int[] even= new int[10];
//int b is for the forloop so that every number can be added
int b;
//
//initialize the scanner, and enter prompt
Scanner input= new Scanner(System.in);
//enter prompt
System.out.printf("Enter 10 random numbers\n");
//make a forloop so every number they put in will be added to the array
for(b=0;b<10;b++)
{
even[b]=input.nextInt();
}
//then run the formula
formula(even[b]);
}
public static void formula(int a)
{
//use an if statement to see if the numbers in the array are odd or even.
for(a=0;a<=10;a++)
{
if((a%2)==0)
{
System.out.printf("This number is even\n");
}
else
{
System.out.printf("This number isn't even\n");
}
}
}
}