Q:

Java Program to check if a Number is Positive or Negative

0

Java Program to check if a Number is Positive or Negative.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.*;
import java.lang.*;
import java.io.*;

public class PositiveNegative {
    public static void main(String[] args) {
        int number = -12;
        if (number < 0.0)
            System.out.println(number + " is a negative number.");
        else if ( number > 0.0)
            System.out.println(number + " is a positive number.");
        else
            System.out.println(number + " is 0.");
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now