0

Help me to find error in my code đŸ„șđŸ„ș

https://code.sololearn.com/cAbi8Ay2c7fL/?ref=app

8th Dec 2022, 3:10 PM
Ashish Kumar
Ashish Kumar - avatar
3 Answers
+ 6
First The Scanner class should be imported at the beginning of the file using the import keyword. ..The next() method of the Scanner class does not return an int value, so you will need to use a method like nextInt() instead. ..The if statement is missing its opening and closing curly braces {}. ..The else statement is also missing its opening and closing curly braces {}. Here is the corrected code: https://code.sololearn.com/cMsb3Z38wTgm/?ref=app
9th Dec 2022, 11:20 AM
Sadaam Linux
Sadaam Linux - avatar
+ 3
Additionally: first import Scanner class. as import java.util.Scanner; And output should match the expected output exactly, from description "Not boiling" remove extra } at end.
8th Dec 2022, 5:45 PM
Jayakrishna 🇼🇳
+ 2
There is a syntax error in the code you provided. In the line int temp = sc.next();, sc.next() should be followed by () to indicate that it is a method call, rather than a variable. Additionally, the method next() does not return an int, so the assignment of temp should be changed to use the nextInt() method instead. Here is the corrected code: public class Program { public static void main(String[] args) { Scanner sc = new Scanner (System.in); int temp = sc.nextInt(); if(temp >= 100) { System.out.println("Boiling"); } else { System.out.println(" not boiling"); } } } }
8th Dec 2022, 3:14 PM
CalviŐČ
CalviŐČ - avatar