This Java program prompts the user to enter three numbers and then determines whether the numbers are all equal, all different, or neither all equal nor all different.
Overall, this program is a simple example of how to use basic conditional statements in Java to compare and classify different values.
import java.util.Scanner; class Number_EqualNot { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter First Number: "); int num1 = in.nextInt(); System.out.print("Enter Second Number: "); int num2 = in.nextInt(); System.out.print("Enter Third Number: "); int num3 = in.nextInt(); if (num1 == num2 && num1 == num3 && num2 == num3) { System.out.println("All Numbers are equal"); } else if ((num1 == num2) || (num1 == num3) || (num3 == num2)) { System.out.println("Neither all are Equal or Different"); } else { System.out.println("All Numbers are Different"); } } }
Enter First Number: 26 Enter Second Number: 45 Enter Third Number: 53 All Numbers are Different
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions