🔒 Closed Even or odd identify in java

Status
Not open for further replies.

Kuroneko - chan

Journeyman
Even or Odd identifier!! Java


Code:
import java.util.Scanner;

public class EvenOrOdd
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        int number;
        System.out.println("Enter a number: ");
        number = in.nextInt();
        
        int n;
        n = number % 2;
        if(n == 0)
        {
            System.out.print("The number " + number + " is Even");
        }
        else
        {
            System.out.println("The number " + number + " is Odd");
        }
    }
}
 
Status
Not open for further replies.

About this Thread

  • 3
    Replies
  • 599
    Views
  • 3
    Participants
Last reply from:
Kuroneko - chan

Online now

Members online
413
Guests online
890
Total visitors
1,303

Forum statistics

Threads
2,275,099
Posts
28,960,643
Members
1,233,594
Latest member
baam
Back
Top