🔒 Closed Help java

Status
Not open for further replies.

Phc-AJDS

Eternal Poster
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]+" ");
}
}
 
Status
Not open for further replies.

About this Thread

  • 2
    Replies
  • 576
    Views
  • 3
    Participants
Last reply from:
lemoneyd

Trending Topics

Online now

Members online
1,086
Guests online
1,685
Total visitors
2,771

Forum statistics

Threads
2,287,384
Posts
29,044,386
Members
1,216,504
Latest member
Jolowewi
Back
Top