Question: Write a program that computes the balance of a customer's bank account based on a transaction type and the amount entered by user. The transaction

Write a program that computes the balance of a customer's bank account based on a transaction type and the amount entered by user.
The transaction input format has one letter, a space, then the transaction amount.
The follwoing are assumed:
The user will enter one letter for transaction type. It can be D,d,w,W, or other letter. D or d stands for deposit and W or w for withdraw.
The transaction amount is entered as an integer and it can be entered as negative. This will generate an error message as shown in the sample run.
The amount of withdraw, if positive cannot exceed the balance. Other wise an error message will be displayed (see sample run).
Each time the user performs a valid transaction, the program will display the new balance.
Once the user is done, he/she will press the ENTER key to terminate. In that case, the program will display the final balance.
Note: to separate the transaction type from the amount after reading the input, the character at index 0 is the transaction type; the substring from index 2 to the end
represents the amount.
Sample run
Your initial balance =0
Enter transaction and amount or press ENTER key to end: T 300
operation type must be D or W
Enter transaction and amount or press ENTER key to end: d1000
After deposit, new balance =1000
Enter transaction and amount or press ENTER key to end: D -500
transaction amount must be >0
Enter transaction and amount or press ENTER key to end: D 600
After deposit, new balance =1600
Enter transaction and amount or press ENTER key to end: w-500
transaction amount must be >0
Enter transaction and amount or press ENTER key to end: W 2000
Not enough fund to withdraw 2000
Enter transaction and amount or press ENTER key to end: W 1100
After withdraw, new balance =500
Enter transaction and amount or press ENTER key to end: D 4100
After deposit, new balance =4600
Enter transaction and amount or press ENTER key to end:
Your final balance =4600
 Write a program that computes the balance of a customer's bank

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!