dimanche 30 mars 2014

Java - While loop not functioning- Bug


Vote count:

0




I'm trying to make a "Bank Account" and that requires the user to input the name, password, balance, and interest of that bank account. I use a sentinel controlledwhile loop to achieve this, but my sentinel does not work for some reason. Here's part of my code, if you could help me that would be great:



System.out.println("New Account: Enter name, type \"quit\" to exit. ");
String name = scan.nextLine();
while (!name.equals("quit")) {
System.out.println("Enter password: ");
String pass = scan.nextLine();
System.out.println("Enter balance (in pennies): ");
double bal = scan.nextDouble();
System.out.println("Enter interest: ");
double inter = scan.nextDouble();

BankAccount2 bankacc = new BankAccount2(name, pass, bal, inter);
accounts.add(bankacc);
System.out.println("Successful account creation! New Account: Enter name, type \"quit\" to exit. ");
name = scan.nextLine();
}


asked 40 secs ago






Aucun commentaire:

Enregistrer un commentaire