Write a program that reads a file called payments.txt, searches for a given customer number, and displays
their total payments for the quarter.
The file contains 4 fields, separated by a | (shift backslash).
Record layout:
transaction # | customer # | customer name | payment amount - field names
104|B4328|Susan Shaw|55.00 - actual record from file
transaction # - integer
customer # - string
customer name – string
payment amount – floating point, 2 decimals
If a customer makes multiple payments during the quarter, there will be multiple records in the file for that
customer. Each payment is recorded with a different transaction #.
Your program should enter the customer number. Successively read each record in the file. Use the
appropriate string manipulation method to extract that record’s individual fields (transaction #, customer #,
name and amount).
If the entered customer number matches the customer number on that record, accumulate their payment
amounts, and store their name.
When all records have been processed, display the customer name and their total payments.
If a customer didn’t make any payments this quarter, display a message.
Test Cases – here are some sample test results. Your output does not have to show each payment amount,
just the total.
Customer # Customer Name Total Payments
C9620 John Beane 500.00 + 55.00 + 100.00 = $655.00
L5508 Steve Sunter 75.00 + 300.00 = $375.00
B4328 Susan Shaw 145.50 + 55.00 + 250.00 + 65.50 = $516.00
Sample Solution