我正在尝试编写代码,要求我插入我的年龄。如果它在10岁以下,我希望它再问我3次。如果它在10以上,它会说“欢迎”。我无法做到这一点。循环扫描仪
package newProject;
import java.util.Scanner;
public class mainclass {
public static void main(String[] args) {
System.out.println("Enter your age");
Scanner age= new Scanner(System.in);
int userage= age.nextInt();
if(userage<10){
for(int x = 3;x<3;x++){
System.out.println(userage+ "is too young");
System.out.println("Enter your age");
int userage1= age.nextInt();
}
}else{
System.out.println("welcome");
}
}
}
除了严重的代码格式问题,我们需要更多的信息,而不仅仅是“它无法做到这一点”。请参阅[如何提问](http://www.stackoverflow.com/help/how-to-ask)。 – CodeMouse92