Answer to Question #3127 in Java | JSP | JSF for ksimran

Question #3127
Input a number and find whether it is positive or negative.
1
Expert's answer
2011-06-15T11:15:43-0400
public class Program {
& public static void main(String[] args) {
& java.util.Scanner kb = new java.util.Scanner(System.in);
& System.out.print("Please enter number: ");
& double number = Double.parseDouble(kb.nextLine());
& if (number<0)
System.out.println("Negative");
& else if (number>0)
System.out.println("Positive");
& else
System.out.println("Zero");
& }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS