Account balance = 107000. When the user inputs 106500 it will give the else statement. Any ideas how to fix this?
while (menuChoice == 1) {
System.out.println("How much do you want to transfer?");
transferAmount = console.nextDouble(); // Getting transfer amount
// from user input
System.out.println("Who do you want to transfer this to?");
transferName = console.next(); // Getting a transfer name from user input
accountBalance = (accountBalance - transferAmount); // The calculation for account balance
if (accountBalance > transferAmount) { // Only allowing transfer if the transfer amount is less than the account balance
System.out.println(""); // spacing out the output
System.out.println("Transfer Complete");
outfile.println("The balance for the port account is £"+ accountBalance + " You have sent £"+ transferAmount + " to " + transferName+ " on the following date and time, " + Date); // Printing line to output file about the transaction details
outfile.close();
menuChoice = 0; // Ending the while loop if true
} else // Denying a transfer if the transfer amount is more than the account balance
System.out.println("Warning You will go overdrawn!");
menuChoice = 0;
}
Aucun commentaire:
Enregistrer un commentaire