我想在选项 3 中打印选项 1 和 2 的输入。我有一个菜单设置,用户选择他们想要的数字,然后在他们选择哪个团队之后有后续问题。
if (choys == 1)
{
ch = new Scanner(System.in);
System.out.println("Enter name: ");
userBName = ch.nextLine();
System.out.println("Enter age: ");
userBAge = ch.nextInt();
if(userBAge >=18 && userBAge <=21)
{
System.out.println("Congrats "+userBName+"! Welcome to the team.");
bslot++;
}
else
{
System.out.println("Sorry "+userBName+". You are not qualified.");
}
}
if (choys == 2)
{
System.out.println("Enter name: ");
userVName = ch.nextLine();
System.out.println("Enter age: ");
userVAge = ch.nextInt();
if(userVAge >=18 && userVAge <=21)
{
System.out.println("Congrats "+userVName+"! Welcome to the team.");
vslot++;
}
else
{
System.out.println("Sorry "+userVName+". You are not qualified.");
}
}
if (choys == 3)
{
System.out.println("Current number of recruits:\n");
System.out.println("Basketball team: "+ userBName+"\n\n");
System.out.println("Volleyball team: "+ userVName);
}
}
慕尼黑5688855
猛跑小猪
相关分类