Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

to compare if three ints = two are equal and one is different

System.out.print("First number: ");
int a = Integer.parseInt(reader.readLine());
System.out.print("Second number: ");
int b = Integer.parseInt(reader.readLine());
System.out.print("Third number: ");
int c = Integer.parseInt(reader.readLine());

if (???????) {
    System.out.println("Two are equal and one is different");
}else{
    System.out.println("....");
}

I don’t know what should be in the if condition.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

One of posibilities can be:

   if ((a == b && b != c) || (a == c && a != b) || (b == c && c != a))

More: How to check if two out of three values are the same?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading