Even Array
Even Array
FLOW CHART
NO START YES
Num= 0
Display odd Display
num even num
Accept
num
END
Num
%2==0
PROBLEM
1.Create a Program that input 10 numbers that determine even or odd .
SOURCE CODE:
package com.even;
import java.util.*;
public class even {
public static void main(String[] args) {
Scanner sc=new Scanner (System.in);
int num[]= new int [10];
System.out.println("Please input 10 number");
for (int x =0;x<num.length;x++){
num[x]=sc.nextInt(); }
System.out.print("The even are/is: ");
for(int x =0;x<num.length;x++){
if (num[x] % 2 == 0)
{ System.out.print(num[x]+" "); }
} System.out.print("\n\n The odd are / is: ");
for(int x =0;x<num.length;x++){
if(num[x] % 2 == 0){}
else{
System.out.print(num[x]+" ");
}
}
}
OUTPUT:
Please input 10 number:
1
2
3
4
5
6
7
8
9
10
The even are/is: 2 4 6 8 10
The odd are/is: 1 3 5 7 9