-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrderCheck.java
More file actions
35 lines (31 loc) · 1.03 KB
/
OrderCheck.java
File metadata and controls
35 lines (31 loc) · 1.03 KB
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
32
33
34
35
import static java.lang.System.out;
/*************************************************************************
* Compilation: javac OrderCheck.java
* Execution: java OrderCheck 5 10 15 2
*
* @author: Taaha Siddiqui
*
* Prints true if the four integer inputs are in strictly ascending
* or descending order, false otherwise
*
* % java OrderCheck 5 10 15 2
* false
*
* % java OrderCheck 15 11 9 4
* true
*
*************************************************************************/
public class OrderCheck {
public static void main(String[] args) {
if (args.length == 4) {
int w = Integer.parseInt(args[0]);
int x = Integer.parseInt(args[1]);
int y = Integer.parseInt(args[2]);
int z = Integer.parseInt(args[3]);
boolean result = (w < x && x < y && y < z) || (w > x && x > y && y > z);
System.out.println(result);
} else {
System.out.println("Please enter four integers as command line arguments");
}
}
}