+ 3
What is wrong with my code?
public class Program { public static void main(String[] args) { Scanner infoInput = new Scanner(System.in); int age = infoInput.nextInt(); if (age < 16) { System.out.println(age+" is young."); } else { System.out.println(age+" is old."); } } }
5 Answers
+ 10
your code is absolutely right
but just before writing the code you should import certain packages (here you should import scanner class which is in util package)
so your code will be
import java.util.*;
public class Program {
public static void main(String[] args) {
Scanner infoInput = new Scanner(System.in);
int age = infoInput.nextInt();
if (age < 16) {
System.out.println(age+" is young.");
} else {
System.out.println(age+" is old.");
}
}
}
+ 7
Welcome brother.
+ 3
Rstar is right.
+ 1
there is no import
+ 1
You guys are awesome! This is why I love this app. Thanks everyone!