use a conditional to check greater than number in java
Code snippet on how to use a conditional to check greater than number in java
int numberA = 5;
int numberB = 10;
if (numberA > numberB) {
System.out.println("Number A is greater than Number B");
}
else {
System.out.println("Number A is not greater than Number B");
}
This code uses a conditional statement to determine if numberA is greater than numberB. It starts by defining two integer variables, numberA and numberB. The ‘if’ statement checks if numberA is greater than numberB and if it is, the code inside the curly braces following the if statement will be executed. This code is simply printing out a message to let the user know the result of the comparison. If numberA is not greater than numberB, the code inside the else statement will be executed, printing out another message to indicate that numberA was not greater than numberB.