import java.util.Scanner;
public class LoopsEndingRemembering {
public static void main(String[] args) {
// program in this project exercises 36.1-36.5
// actually this is just one program that is split in many parts
Scanner reader = new Scanner(System.in);
System.out.println("Type numbers: ");
int input = Integer.parseInt(reader.nextLine());
while(true){
if(input == -1){
break;
}
}
System.out.println("Thank you and see you later!");
}
}
用户应该可以输入多个数字,直到达到-1。一旦到达它应该中断循环并打印最后一行。
答案 0 :(得分:4)
您需要输入
System.out.println("Type numbers: ");
int input = Integer.parseInt(reader.nextLine());
进入循环,否则将永远不会获得新的用户输入
答案 1 :(得分:0)
您需要在循环内使用呼叫扫描器
my_list = []
stage_list = []
mic_list = []
all_list = []
def addto_list():
addto = input()
for str in addto:
input("Can he do stage?(y/n): ")
if input == "y":
stage_list.append(addto)
else:
break
for str in addto:
input("Can he do mic?(y/n): ")
if input == "y":
mic_list.append(addto)
else:
break
for str in addto:
input("Can he do sound?(y/n): ")
if input == "y":
all_list.append(addto)
else:
break
my_list.append(addto)