0
[WHAT IS WRONG WITH MY CODE?] A java program that determines whether an integer is Positive or Negative
import java.util.Scanner; public class Postive_Negative { public static void main (Strings[] args) { int n; Scanner s = new Scanner(System.in); n = s.nextInt(); if(n > 0) { System.out.printIn("Positive"); } else if(n < 0) { System.out.printIn("Negative"); } else { System.out.printIn("Neither Positive nor Negative"); } } }
6 odpowiedzi
+ 2
First of all, you putted an extra "s" in the main function arguments. In addition, you should write println, rather than printIn (L, not I)
So here is a working code:
https://code.sololearn.com/c0Vel0N2X1v6/?ref=app
+ 2
ruiririririri, No problem 👍
And happy learning!
+ 2
Hi Martin Taylor I already figured out what you meant. Thank you for explaining it. I really appreciate it. Have a nice day!
+ 1
Aleksei Radchenkov Oh, I see. Thank you very much! Have a nice day!
+ 1
Aleksei Radchenkov I have a follow-up question. I hope it’s okay Ma’am/Sir. What does this phrase mean?
“Main.java:2: error: class Positive_Negative is public, should be declared in a file named Postive_Negative.java”