0
please tell me what is the error?? i need to give age as input
import java.util.Scanner ; public class Program { public static void main(String[] args) { Scanner age = new Scanner(Systrm.in) ; if(age <= 0){ System.out.println("Error"); } else if(age <= 16) { System.out.println("Too Young"); } else if(age < 100) { System.out.println("Welcome!"); } else { System.out.println("Really?"); } } }
9 Réponses
+ 1
age is not defined anywhere
+ 1
check this line
Scanner age= new Scanner(System.in);
spelling of System is wrong
+ 1
int age = ageScan.nextInt();
+ 1
int age = ageScan.nextInt();
You need to define what age is.
0
import java.util.Scanner ;
public class Program {
public static void main(String[] args) {
Scanner ageScan = new Scanner(System.in) ;
age =ageScan.nextint();
if(age < 0){
System.out.println("Error");
} else if(age < 16) {
System.out.println("Too Young");
} else if(age < 100) {
System.out.println("Welcome!");
} else {
System.out.println("Really?");
}
}
}
i made it like this
0
but still error
0
age=ageScan.nextInt();
0
canot find symbol age
0
it works when i put int age after main opening