Scanner scanner = new Scanner(System.in);
int number = scanner.nextInt();
if(number > 5) {
System.out.println("The number is greater than 5");
}
else if(number < 5){
System.out.println("The number is less than 5");
} else {
System.out.println("The number is equal to 5");
}
Solution
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Josip Batinić
24 February 2023, 13:47
I see no problem with your code. Did you put your code inside Solution class and main method?
Just copy paste your code inside curly braces of the main method.
Also, import java.util.Scanner; if you haven`t done that.
Hope this helps... +1