Sure! Here’s a Java program that takes an input from the user and checks if the number is greater than 100 or not:
```java import java.util.Scanner;
public class CheckNumber { public static void main(String[] args) { Scanner scanner = new Scanner(System.in);
System.out.print("Enter a number: ");
int number = scanner.nextInt();
if (number > 100) {
System.out.println("The number is greater than 100.");
} else {
System.out.println("The number is not greater than 100.");
}
scanner.close();
} } ```
In this program, we use the Scanner class to take input from the user. The user is prompted to enter a number, which is stored in the number variable. We then use an if statement to check if the number is greater than 100. If it is, we print “The number is greater than 100.” Otherwise, we print “The number is not greater than 100.” Finally, we close the Scanner object to release any system resources associated with it.
Loading...