Advertisement
ralphdc09

itf103.md-wk-11-wk-13.number01

May 15th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. package md.WK11toWK13;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class number01 {
  6.     public static void main(String[] args) {
  7.         int number;
  8.         Scanner ralph = new Scanner(System.in);
  9.  
  10.         System.out.print("Enter a number and check if it's positive or negative: ");
  11.         number = ralph.nextInt();
  12.  
  13.     /*
  14.        else if statement guide
  15.        if number is greater than 0 , number is positive
  16.        else if number is less than 0 , number is negative
  17.        else , number is neither a positive or negative
  18.     */
  19.         if (number > 0) {
  20.             System.out.println("The number " + number + " is positive! ");
  21.         } else if (number < 0) {
  22.             System.out.println("The number " + number + " is negative! ");
  23.         } else {
  24.             System.out.println("The number " + number + " is neither positive or negative! ");
  25.         }
  26.     }
  27. }
  28.  
  29.  
  30.  
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement