File tree
Expand file treeCollapse file tree1 file changed
+31
-0
lines changed Expand file treeCollapse file tree1 file changed
+31
-0
lines changed Original file line number | Diff line number | Diff line change |
---|
|
| 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 | +} |
You can’t perform that action at this time.
0 commit comments