do
{
System.out.println("Enter what would you like to do\n");
System.out.println("D--Deposite, W--Withdraw, C--Check Balance, E--Exit");
System.out.print("Enter your selection now: ");
choices = key.nextLine();
if(choices.equals("W") || choices.equals("w"))
{
System.out.println("You have selected with draw\n");
System.out.print("Please enter the amount you want to with draw: \n");
withdraw = key.nextInt();
totalamount -= withdraw;
}
else if(choices.equals("C") || choices.equals("c"))
{
System.out.println("You have selected check balance\n");
System.out.print("Your account balance is " + totalamount + "\n" );
}
else if(choices.equals("d") || choices.equals("D"))
{
System.out.println("You have selected deposite\n");
System.out.print("Please enter the amount you want to deposite: ");
depot = key.nextInt();
totalamount += depot;
}
else if(choices.equals("E") || choices.equals("e"))
{
System.exit(0);
}
}while(true);
here is the output from my code
Please enter your pin number: 111
Enter what would you like to do
D--Deposite, W--Withdraw, C--Check Balance, E--Exit
Enter your selection now: Enter what would you like to do
D--Deposite, W--Withdraw, C--Check Balance, E--Exit
Enter your selection now:
So, whenever it gets into the do-while loop it prints out this part twice
D--Deposite, W--Withdraw, C--Check Balance, E--Exit
Enter your selection now: Enter what would you like to do
D--Deposite, W--Withdraw, C--Check Balance, E--Exit
Enter your selection now:
Can anyone please point out to me where is my error, thx?

New Topic/Question
Reply




MultiQuote







|