Java program to check the given number is positive or negative
KW.java
importjava.util.Scanner;classKW{publicstaticvoidmain(Stringargs[]){intn;Scannersc=newScanner(System.in);System.out.println("———————————————————————————————————————————");System.out.println("Program to check the given number is +ve/-ve");System.out.println("———————————————————————————————————————————");System.out.print("Enter a number ");n=sc.nextInt();if(n<0){System.out.println("\nEntered number is negative");}elseif(n>0){System.out.println("\nEntered number is positive");}else{System.out.println("\nEntered number is zero");}System.out.println("———————————————————————————————————————————");}}
Output
kodingwindow@kw:~$ javac KW.java kodingwindow@kw:~$ java KW
———————————————————————————————————————————
Program to check the given number is +ve/-ve
———————————————————————————————————————————
Enter a number 0
Entered number is zero
———————————————————————————————————————————
kodingwindow@kw:~$
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?