0
Help me to find error in my code đ„șđ„ș
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
+ 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.
+ 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");
}
}
}
}