-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEqual113.java
27 lines (25 loc) · 916 Bytes
/
Equal113.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
/**
* Write a program that takes three integer command-line arguments and prints
* equal if all three are equal, and not equal otherwise.
*/
public class Equal113 {
public static void main(String[] args) {
// Check if there are exactly 3 command-line arguments
if (args.length != 3) {
System.out.println("Please provide exactly three integer command-line arguments.");
return;
}
try {
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = Integer.parseInt(args[2]);
if (a == b && b == c) {
System.out.println("equal");
} else {
System.out.println("not equal");
}
} catch (NumberFormatException e) {
System.out.println("Please provide valid integer values as command-line arguments.");
}
}
}