Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class NumberEqualityChecker {
- 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 the first number
- System.out.print("Enter the first number: ");
- int num1 = scanner.nextInt();
- // Prompt the user to enter the second number
- System.out.print("Enter the second number: ");
- int num2 = scanner.nextInt();
- // Prompt the user to enter the third number
- System.out.print("Enter the third number: ");
- int num3 = scanner.nextInt();
- // Close the Scanner
- scanner.close();
- // Check if all numbers are equal
- if (num1 == num2 && num2 == num3) {
- System.out.println("All numbers are equal.");
- }
- // Check if all numbers are different
- else if (num1 != num2 && num2 != num3 && num1 != num3) {
- System.out.println("All numbers are different.");
- }
- // If neither all are equal nor all are different
- else {
- System.out.println("Neither all are equal nor all are different.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement