Sign of an integer
Sign of an integer
Problem Description
Java Program to find the sign of an integer
Example:
0 Is equal to zero
-25 Negative
25 Positive
Logic Test Case 1
Input (stdin)
9
Expected Output
Positive
Logic Test Case 2
Input (stdin)
-34
Expected Output
Negative
CODE AREA.
import java.io.*;
import java.util.Scanner;
public class TestClass {
public static void main(String[] args) {
int a;
Scanner in=new Scanner(System.in);
a=in.nextInt();
if(a>0)
{
System.out.println("Positive");
}
else
{
System.out.println("Negative");
}
}
}
0 Comments