1. Write a program in Java to print whether the number is positive or negative as per the input given by the user.
Code
import java.util.Scanner;public class Numberpositiveornegative {public static void main(String args[]){Scanner a = new Scanner(System.in);System.out.println("Enter the Number");int Num = a.nextInt();if(0>Num){System.out.println("Number is Negative");}elseSystem.out.println("Number is Positive");}}
Output
Enter the Number
-5
Number is Negative
0 Comments