22nd Jun 2018, 9:16 AM
K Yash
K Yash - avatar
8 Respostas
+ 4
in line 4, change to this: Scanner age=new Scanner(System.in); in line 5, change the variable name. you can't have 2 variables with same name in java program.
22nd Jun 2018, 9:31 AM
Lucky Luke
0
import java.util.*; public class Program { public static void main(String[] args) { System.out.println("Enter Age"); Scanner ageInput = new Scanner(System.in); int age = ageInput.nextInt(); if(age > 0) { if(age > 16) { System.out.println("Welcome!"); } else { System.out.println("Too Young"); } } else { System.out.println("Error"); } } }
22nd Jun 2018, 9:33 AM
CHMD
CHMD - avatar
0
now why it's not coming
22nd Jun 2018, 9:36 AM
K Yash
K Yash - avatar
0
Line 7, nextInt is a function, you need to add parentheses at the end. a = in.nextInt();
22nd Jun 2018, 9:38 AM
CHMD
CHMD - avatar
22nd Jun 2018, 9:38 AM
K Yash
K Yash - avatar
0
okay sir..
22nd Jun 2018, 9:38 AM
K Yash
K Yash - avatar
0
thanku sir..
22nd Jun 2018, 9:40 AM
K Yash
K Yash - avatar