Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package md.WK11toWK13;
- import java.util.Scanner;
- public class number01 {
- public static void main(String[] args) {
- int number;
- Scanner ralph = new Scanner(System.in);
- System.out.print("Enter a number and check if it's positive or negative: ");
- number = ralph.nextInt();
- /*
- else if statement guide
- if number is greater than 0 , number is positive
- else if number is less than 0 , number is negative
- else , number is neither a positive or negative
- */
- if (number > 0) {
- System.out.println("The number " + number + " is positive! ");
- } else if (number < 0) {
- System.out.println("The number " + number + " is negative! ");
- } else {
- System.out.println("The number " + number + " is neither positive or negative! ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement