-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAllEqual.java
31 lines (25 loc) · 862 Bytes
/
AllEqual.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
Write a program AllEqual.java that takes three integer command-line arguments and prints true if all three are equal, and false otherwise.
*/
public class AllEqual
{
public static void main(String[] args)
{
/*
We can only compare three variable at once using the AND operator (&&).
AND:
True True = True
True False = False
False True = False
False False = False
So if a = b and b = c which means a also equals c then only status1 would have the value True.
*/
// Taking three integers as input from Command Line
int a = Integer.parseInt (args[0]);
int b = Integer.parseInt (args[1]);
int c = Integer.parseInt (args[2]);
boolean status1 = (a==b) && (b==c);
// Printing the result that is stored in variable status1
System.out.println(status1);
}
}