Write a class OddExample to accept a number to find whether the number is Odd or Even

0

Assignment: Module 03- Part 02

Write a class OddExample to accept a number to find whether the number is Odd or Even
Assignment: Module 03- Part 02
Write a class Odd Example to accept a number to find whether the number is Odd or Even

Input: 

Enter the no. 4

Output: 

The given no is even

Input: 

Enter the no. 3

Output: 

The given no is odd

Here is the Java code for the class OddExample:

import java.util.Scanner;

public class OddExample {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.print("Enter the no.: ");
    int num = sc.nextInt();
    if (num % 2 == 0) {
      System.out.println("The given no is even");
    } else {
      System.out.println("The given no is odd");
    }
  }
}   

Output

Enter the no.: 4
The given no is even

Enter the no.: 3
The given no is odd   

👉Write a class MultiplicationtTable to accept a number to find the table calculation of it till 10.👈

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !
✨ Updates