ask=1;
while(ask==1)
{
System.out.println("What is your phrase?");
phrase=sc.nextLine();
System.out.println("What is your additive key?");
key=sc.nextInt();
String code=addit(phrase, key);
System.out.println(code);
System.out.println("Enter 1 to go again");
ask=sc.nextInt();
}
直接跳过询问我的添加键是在第一次通过循环之后是谁知道为什么?
答案 0 :(得分:1)
所以,根据@PakkuDon的说法,这应该可以解决问题:
ask = 1;
while(ask == 1)
{
System.out.println("What is your phrase?");
phrase = sc.nextLine();
System.out.println("What is your additive key?");
key = sc.nextInt();
String code = addit(phrase, key);
System.out.println(code);
System.out.println("Enter 1 to go again");
ask = sc.nextInt();
String tmp = sc.nextLine();
}