Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class OddEvenChecker {
- public static void main(String[] args) {
- // Create a Scanner object to read input from the user
- Scanner scanner = new Scanner(System.in);
- // Prompt the user to enter a number
- System.out.print("Enter a number: ");
- // Read the number from the user
- int number = scanner.nextInt();
- // Close the Scanner
- scanner.close();
- // Check if the number is odd or even
- if (number % 2 == 0) {
- System.out.println(number + " is even.");
- } else {
- System.out.println(number + " is odd.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement