[WHAT IS WRONG WITH MY CODE?] A java program that determines whether an integer is Positive or Negative | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
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"); } } }

6th Oct 2021, 7:42 AM
ruiririririri
ruiririririri - avatar
5 Réponses
+ 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
6th Oct 2021, 7:51 AM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 2
ruiririririri, No problem 👍 And happy learning!
6th Oct 2021, 7:59 AM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 2
Hi Martin Taylor I already figured out what you meant. Thank you for explaining it. I really appreciate it. Have a nice day!
6th Oct 2021, 10:07 AM
ruiririririri
ruiririririri - avatar
+ 1
Aleksei Radchenkov Oh, I see. Thank you very much! Have a nice day!
6th Oct 2021, 7:53 AM
ruiririririri
ruiririririri - avatar
+ 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”
6th Oct 2021, 8:05 AM
ruiririririri
ruiririririri - avatar