What's new

Help java

Phc-AJDS

Eternal Poster
Joined
Feb 26, 2017
Posts
718
Reaction
905
Points
356
Write a program using one-dimensional array that determines the even numbers among the ten input values from the keyboard and prints the list of these Even numbers.

sample:

Enter ten numbers:

8 9 7 10 25 30 69 101 1001 798

Here is the list of Even number/s:

8 10 30 798
 
int[] num2 = new int[10];
System.out.println("Enter ten numbers:");
for (int x=0;x<10;x++){
System.out.println("Number "+(x+1)+":");
Scanner myObj = new Scanner(System.in); // Create a Scanner object
int num = myObj.nextInt();
num2[x]= num;
}
System.out.println("Here is the list of Even number/s:");
for (int x=0;x<10;x++){
if(num2[x]%2==0){
System.out.print(num2[x]+" ");
}
}
 

Similar threads

Back
Top