Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class NumberAnalyzer {
- public static void main(String[] args) {
- // Create a Scanner object to read input from the user
- Scanner scanner = new Scanner(System.in);
- // Prompt the user to enter a float value
- System.out.print("Enter a float value: ");
- // Read the float value from the user
- float number = scanner.nextFloat();
- // Close the Scanner
- scanner.close();
- // Check if the entered number is ZERO
- if (number == 0) {
- System.out.println("ZERO");
- }
- // Check if the entered number is positive
- else if (number > 0) {
- // Check if the positive number is less than 1
- if (number < 1) {
- System.out.println("small positive");
- }
- // Check if the positive number is greater than or equal to 1,000,000
- else if (number >= 1000000) {
- System.out.println("large positive");
- }
- // If the positive number doesn't meet the above conditions
- else {
- System.out.println("positive");
- }
- }
- // Check if the entered number is negative
- else {
- // Check if the negative number is greater than -1 (but not equal to 0 or -1)
- if (number > -1) {
- System.out.println("small negative");
- }
- // Check if the negative number is less than or equal to -1,000,000
- else if (number <= -1000000) {
- System.out.println("large negative");
- }
- // If the negative number doesn't meet the above conditions
- else {
- System.out.println("negative");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement