Skip to content

Commit f420dc9

Browse files
committed
Check Nums
1 parent 731b912 commit f420dc9

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/easy/CheckNums.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package easy;
2+
3+
/**
4+
* Have the function CheckNums(num1,num2) take both parameters
5+
* being passed and return the string true if num2 is greater
6+
* than num1, otherwise return the string false.
7+
* If the parameter values are equal to each other, then return the string -1.
8+
*/
9+
public class CheckNums {
10+
11+
/**
12+
* Check Nums function.
13+
*
14+
* @param num1 first number to compare
15+
* @param num2 second number to compare
16+
* @return result of the comparison
17+
*/
18+
private static String checkNums(int num1, int num2) {
19+
if (num1 == num2) {
20+
return "-1";
21+
}
22+
return num2 > num1 ? "true" : "false";
23+
}
24+
25+
/**
26+
* Entry point.
27+
*
28+
* @param args command line arguments
29+
*/
30+
public static void main(String[] args) {
31+
var result1 = checkNums(63, 16);
32+
System.out.println(result1);
33+
var result2 = checkNums(50, 50);
34+
System.out.println(result2);
35+
var result3 = checkNums(70, 60);
36+
System.out.println(result3);
37+
}
38+
39+
}

0 commit comments

Comments
 (0)