What is wrong with my code? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 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."); } } }

19th Feb 2018, 5:23 AM
John Raymond Notarte
John Raymond Notarte - avatar
5 Respuestas
+ 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."); } } }
19th Feb 2018, 6:02 AM
Rstar
Rstar - avatar
+ 7
Welcome brother.
21st Feb 2018, 10:46 AM
Rstar
Rstar - avatar
+ 3
Rstar is right.
20th Feb 2018, 2:04 PM
Ahmed Ali Alqahtani
+ 1
there is no import
21st Feb 2018, 8:33 AM
Elio Whbe
Elio Whbe - avatar
+ 1
You guys are awesome! This is why I love this app. Thanks everyone!
21st Feb 2018, 8:52 AM
John Raymond Notarte
John Raymond Notarte - avatar