The ATM Transaction Validator requires a loop and if-then logic. You will write
ID: 3542484 • Letter: T
Question
The ATM Transaction Validator requires a loop and if-then logic. You will write the output to a file called statement.txt and read in a file called customer.txt which contains the following information on each line of the file:
Customer last name (two words followed by a comma as a delimiter)
Checking account balance
Transaction type code
Transaction amount
Provide an appropriate error message if the file cannot be found.
Remember to echo each input item as well
A negative amount should cause an error message to be written and the transaction ignored
Invalid transaction types must be reported as errors
All monetary values should be printed with 2 decimal places.
Transaction type codes are (W)ithdraw, (D)eposit, (R)eport the balance
At the end of the transaction the program writes out the new balance or why it couldn't be done.
In any case, if the ending balance is below $300, a warning message should be printed
You need to create the input data file (customer.txt) and use the following data to test your program:
Joe Turing, 4124.50 D 200
Charles Babbage, 300.00 D 100
Sam Backus, 350.25 W 51
Sam Hopper, 600.50 X 600
Robert McCarthy, 1000.00 R 0
Jack Atanasoff, 200.00 W 200
Anne Stroustrup, 300.75 W 301
Amanda Hollerith, 500.00 W -2
Explanation / Answer
Customer Name : Joe Turing
Checking Balance Before Transaction: $ 4124.50
Transaction Type: D
Transaction Amount: $ 200
Checking Balance After Transaction: $ 4324.50
Customer Name : Charles Babbage
Checking Balance Before Transaction: $ 300.00
Transaction Type: D
Transaction Amount:$ 100
Checking Balance After Transaction:$ 400.00
Customer Name :Sam Backus
Checking Balance Before Transaction:$ 350.25
Transaction Type: W
Transaction Amount:$ 51
warning : Account is below minimum $ 300.00
Checking Balance After Transaction:$ 299.25
Customer Name :Sam Hopper
Checking Balance Before Transaction:$ 600.50
Transaction Type:X
Transaction Amount:
Checking Balance After Transaction:
Customer Name : Robert McCarthy
Checking Balance Before Transaction: $1000.00
Transaction Type:R
Transaction Amount:$ 0
Checking Balance After Transaction:$ 1000.00
Customer Name : Jack Atanasoff
Checking Balance Before Transaction:$ 200.00
Transaction Type: W
Transaction Amount:$ 200
Checking Balance After Transaction:$ 400.00
Customer Name : Anne Stroustrup
Checking Balance Before Transaction: $ 300.75
Transaction Type: W
Transaction Amount: $ 301.00
Error: No enough balance
Checking Balance After Transaction:
Customer Name :Amanda Hollerith
Checking Balance Before Transaction:$ 500.00
Transaction Type: W
Transaction Amount:$ -2
Error : Invalid data
Checking Balance After Transaction:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.