Java program to find positive and negative number

Java program to find negative number

Java program to find positive number

Program:-

import java.util.Scanner;

class group{
public static void main(String angt[]){
Scanner data = new Scanner(System.in);
int num, n1=0;
System.out.println("Enter a number");
num=data.nextInt();
// Finding absolute value
n1=Math.abs(num);
num=num-n1;
if(num==0)
System.out.println("Positive Number");
else
System.out.println("Negative Number");
}
}

Output:-

Enter a number
-52
Negative Number

Output:-

Enter a number
21
Positive Number



Learn Java:-
Java codes

Java Programs:-
List of Java Programs

Leave reply

Add your comments here

Back to Top