Skip to content

Commit e34e881

Browse files
committed
Positive or Negative
1 parent e1d6b91 commit e34e881

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.java.basic;
2+
3+
import java.util.Scanner;
4+
5+
/*
6+
* Positive Or Negative
7+
*
8+
* An integer is a whole number that can be either
9+
* greater than 0, called positive, or less than 0,
10+
* called negative.
11+
*
12+
* Zero is neither positive nor negative.
13+
*
14+
* 100 is Positive Number
15+
* -22 is Negative Number
16+
*
17+
*/
18+
public class PositiveOrNegative {
19+
public static void main(String[] args) {
20+
Scanner scanner = new Scanner(System.in);
21+
System.out.println("Enter any integer : ");
22+
23+
int n = Integer.parseInt(scanner.nextLine().trim());
24+
if(n > 0 )
25+
System.out.println(n+" is a Positive Number.");
26+
else if( n < 0 )
27+
System.out.println(n+" is a Negative Number.");
28+
else
29+
System.out.println("Zero is neither Positive nor Negative.");
30+
31+
scanner.close();
32+
}
33+
}
34+
/*
35+
OUTPUT
36+
37+
Enter any integer : 155
38+
155 is a Positive Number.
39+
40+
Enter any integer : -77
41+
-77 is a Negative Number.
42+
43+
Enter any integer : 0
44+
Zero is neither Positive nor Negative.
45+
*/

0 commit comments

Comments
 (0)