Objective:
Write a Java program that reads a floating-point number and prints "zero" if the number is zero. Otherwise, print "Positive" or "Negative". Add "small" if the absolute value of the number is less than 1, or "large" if it exceeds 1,000,000.
Conditions:
User Input = 0
Output = Zero
User Input =3
Output = Positive
User Input = -99
Output = Negative
User Input = 0.4
Output = Small
User Input = 1988000
Output = Large
Sample Input
User Input = 445
Output = Positive Number
User Input = 10000000
Output = Large
Code
public class floatingpointNumber {
public static void main (String args[]){
System .out.println("Enter the Number");
Scanner sc = new Scanner (System.in);
float Num = sc.nextInt();
if(Num > 0 && Num<100000){
System.out.println("Positive Number");
}
if(Num < 0){
System.out.println("Negative Number");
}
if(Num == 0){
System.out.println("Zero");
}
if(0 <= Num && Num <=1){
System.out.println("Small");
}
if(Num >=1000000){
System.out.println("Large");
}
}
}
0 Comments