Question: Problem 3: Bank transactions Write a program to simulate bank transactions. The program repeats bank transactions until the user stops. First, ask for the transactions;
Problem 3: Bank transactions Write a program to simulate bank transactions. The program repeats bank transactions until the user stops. First, ask for the transactions; options are deposit, withdrawal, and quit. Entering "D' selects deposit, "W" selects withdrawal, "Q" selects quitting the program. Reject transactions with a negative amount or transactions that overdraw the account. Provide one source file ( java) for one question. Hence, total three java files need to be submitted. To help your work, incomplete source files are attached. Use the provided source files to answer the questions. GroceryDiscount, PrintMultiplicationTable Problem 3, respectively. In modifying the source files, 1. 2. Do not change the file (class) names. Points will be deducted if you have different names. Fill in your name in the @author section of the comment in each of the file. If you do not, points will be deducted. Sample run of Bank Transaction Current balance1300.8 Select transaction options: (D)eposit (w)ithdrawal (Q)uit program Current balance:158.e Select transaction options (D)eposit (W) thdrawal (Q)uit program N. Enter an amount to withdraw. 2e8 Sorry, this would overdraw the account. wrong option! Please select again. Current balance:300.e select transaction options: (D)eposit (W) thdrawal (Quit program Current balance: 1se.e Select transaction options: (D)eposit (W)ithdrawal Q)uit progran Enter an amount to deposit. 5e Terminating the program. Current balance:35e.e Select transaction options: ( D ) epos it (w)ithdrawal (Q)uit program Enter an amount to deposit. Enter a positive amount. Current balance:3se.e select transaction options: (o)eposit (W)ithdrawal (Q)uit program Enter an anount to withdrau. Enter a positive amount. Current balance135e.e Select transaction options: (D)eposit withoranal Q)uit prog am Enter an ancunt to withdrau. public static void main(Stringl] args) f double currentBalance 380; boolean continueTransaction true; I/ when the user select Quit option, set continueTransaction false Scanner in new Scanner(System.in) while(continueTransaction) I continue as long as continueTransaction is true System.out.printinO System.out.printIn): System.out.printin("Current balance:" +currentBalance); System.out.printin("Select transaction options:"); System.out.println( (D)eposit"Type "D" for deposit option System.out.println("(W)ithdrawal"); I Type "W" for withdraval option System.out.printin (Quit program) I/ Type " to quit the program String option in.next); if(option.equals("D")) (I/ Complete option D is provided for your reference. System.out.printin("Enter an amount to deposit.") double amount in.nextDouble); if(amount >0) { currentBalance amount else ( System.out.println("Enter a positive amount."); )else ifO (/ Complete Withdraw option }else f() { // Complete Quit option else ( System.out.printin("Wrong option! Please select again.") in.closeO
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
