0% found this document useful (0 votes)
27 views

Even Array

The document describes an algorithm and program to determine if input numbers are even or odd. The algorithm accepts a number from the user, uses the modulo operator to check if the number is evenly divisible by 2, and displays whether it is even or odd. The program implements this algorithm by: 1) Prompting the user to input 10 numbers, 2) Storing the numbers in an array, 3) Printing the even numbers with a modulo check, and 4) Printing the odd numbers with a complementary modulo check.

Uploaded by

Ai Rell
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Even Array

The document describes an algorithm and program to determine if input numbers are even or odd. The algorithm accepts a number from the user, uses the modulo operator to check if the number is evenly divisible by 2, and displays whether it is even or odd. The program implements this algorithm by: 1) Prompting the user to input 10 numbers, 2) Storing the numbers in an array, 3) Printing the even numbers with a modulo check, and 4) Printing the odd numbers with a complementary modulo check.

Uploaded by

Ai Rell
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

ALGORITHM

1.Accept a number from user.


2.Test the input number if it is an even number divide by 2 if the
remainder is 0 it is an even number else is an odd.
3.Display if even number or else it is an odd.

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

You might also like