Write Java code that determines if each value 0 through 10 ispresent in the arra
ID: 3613870 • Letter: W
Question
Write Java code that determines if each value 0 through 10 ispresent in the array. If the array contains a value i, itwill print a message saying that i occurs in thearray.Example:
Say the array contains these values: 3,10,3,11,0,10,3,-7,14,3
The code would print out:
Occurs in array: 0
Occurs in array: 3
Occurs in array:10
This is what I have but it prints the values in the array multipletimes. How can I get it to just print out the
values inside the array once?
int[] list = { 3, 10, 3, 11, 0, 10,3,-7,14,3 };
int i=0;
for ( i=0; i < list.length; i++){
if (list[i] >=0&& list[i]<=10)
System.out.println("Occurs in array: " +list[i]);
}
}
}