0

I want 2 scan age directly n place that in if statement. (Input of age have to place in age in if statement).can any1 correct me

import java.util.Scanner ; class Facebook { public static void main(String[]args){ Scanner variable = new Scanner (System.in) ; String age; age = variable.nextLine(); System.out.println("what is your age?"); int age = 30; if (age<16){ System.out.println("too young") ; } else { System.out.println("welcome") ; } } }

29th May 2017, 1:38 PM
Priya Prathi
2 odpowiedzi
+ 4
try out changing the type of age to int and successively the nextline function
29th May 2017, 2:09 PM
Sumanth .p
Sumanth .p - avatar
0
thanks bro it works!
29th May 2017, 3:03 PM
Priya Prathi