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"); } } }
1 ответ
+ 3
nextLine return String, but x are int. Parse the input to int first then assign to x
x = Integer.parseInt(Age.nextLine());