THIS IS MY CODE ,WHY DOES'NT IT RUN??!!! ,PLEASE HELP | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

THIS IS MY CODE ,WHY DOES'NT IT RUN??!!! ,PLEASE HELP

import java.util.Scanner; class Main { public static void main(String[] args) { Scanner Age = new Scanner(System.in); int x; x = Age.nextLine(); if(x > 18 && x<50) { System.out.println("welcome to the club"); } else { System.out.println("you are not accepted"); } } }

30th Oct 2018, 4:05 PM
mohamad hoseyn
mohamad hoseyn - avatar
1 Answer
+ 3
nextLine return String, but x are int. Parse the input to int first then assign to x x = Integer.parseInt(Age.nextLine());
30th Oct 2018, 4:09 PM
Taste
Taste - avatar