0
help me with this code
can anyone make this code work import java.util.Scanner; public class Program{ public static void main(String[] args) { System.out.println("enter your age"); Scanner reader = new Scanner(System.in); int age = reader.nextInt(); System.out.println("Your age is "+age); if(age < 10) { System.out.println("You are eligible to enter "); } else { System.out.println("You are not eligible to enter."); } } } }
3 Réponses
+ 3
You made a single mistake by adding a closing curly brace "}" at the end which does nothing, just remove the last brace
eg
https://code.sololearn.com/cs9sGW6kAS9J/?ref=app
+ 2
You have an extra }. Try indentating correctly so you detect this kind of mistakes easily.
import java.util.Scanner;
public class Program{
public static void main(String[] args) {
System.out.println("enter your age");
Scanner reader = new
Scanner(System.in);
int age = reader.nextInt();
System.out.println("Your age is "+age);
if(age < 10) {
System.out.println("You are eligible to enter ");
} else {
System.out.println("You are not eligible to enter.");
}
}
}
+ 1
thanks guys