File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import java.util.Scanner;
2+
3+
public class PositiveNegative {
4+
5+
public static void main(String[] args) {
6+
7+
int num; //Declaring Variables
8+
9+
System.out.println("Program to check if the entered number (int) is Positive or Negative.\n---");
10+
11+
Scanner sm = new Scanner(System.in);
12+
13+
System.out.print("Please enter the number: ");
14+
num = sm.nextInt();
15+
sm.close();
16+
17+
if (num>0) {
18+
System.out.println("The number you have entered is Positive.");
19+
}
20+
else if (num==0) {
21+
System.out.println("The number you have entered is ZERO.");
22+
}
23+
else {
24+
System.out.println("The number you have entered is Negative.");
25+
}
26+
27+
System.out.println("---\nThe Program has ended.");
28+
29+
}
30+
31+
}

0 commit comments

Comments
 (0)