-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain3.java
More file actions
30 lines (20 loc) · 753 Bytes
/
Main3.java
File metadata and controls
30 lines (20 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package ifelsejava;
import java.util.Scanner;
public class Main3 {
public static void main(String[] args) {
int number;
Scanner input = new Scanner(System.in);
System.out.println("Check whether a number is negative, positive or zero.\n");
System.out.print("Enter a number: ");
number = input.nextInt();
if (number > 0) {
System.out.println(number + " is positive number.");
} else if(number < 0){
System.out.println(number + " is negative number.");
} else if(number == 0){
System.out.println("Zero Detected!");
} else{
System.out.println("Invalid input!");
}
}
}