一次迭代后它应该再次要求继续吗? (是/否)请帮助!! Thnxx提前
public void demo()
{
System.out.println("Withdrawal or deposit? (w/d) :");
char choice = s.next().charAt(0);
System.out.println("Checking or Savings? (c/s) :");
char choicetwo = s.next().charAt(0);
System.out.println("Amount? : ");
int amt = s.nextInt();
}
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
Child c = new Child();
c.display();
c.demo();
System.out.println("Continue? : ");
char input = s.next().charAt(0);
while(input == 'y')
{
c.demo();
}
答案 0 :(得分:0)
您需要将变量赋值放入while循环中:
System.out.println("Continue? : ");
char input = s.next().charAt(0);
while(input == 'y')
{
c.demo();
System.out.println("Continue? : ");
input = s.next().charAt(0);
}
答案 1 :(得分:0)
System.out.println("Continue? : ");
char input = s.next().charAt(0);
while(input == 'y')
{
c.demo();
System.out.println("Continue? : ");
input = s.next().charAt(0);
}