Write a C++ program (use dynamic memory allocation) that readsN customer records from a text file(customers.txt) such that the number of therecords is stored on the first line in the file. Each record has 4fields (pieces of information) and stored in the file as shownbelow:
Account Number (integer)
Customer full name (string)
Customer email (string)
Account Balance (double)
The program is expected to print the records in the format shownbelow, sorted in decreasing order based on the account balance:
Account Number : 1201077
Name : Jonathan I. Maletic
Email : jmaletic@ksu.edu
Balance : 10,000.17
————————————-
Note: The records stored in the followingformat (4 lines for each account):
First Line is the account number
Second Line is full name
Third line is an email
Forth line is the available balance
Important Note: You must use 4 dynamic arrays(one for each field) to store all the records (information) readfrom the file. Then sort the arrays and then print it. The programshould open the files and read the first token and use it size forthe dynamic array.
Example (data saved in the text file) |
Output: |
3 1201077 Jonathan I. Maletic jmaletic@ksu.edu 10,000.17 1991999 Saleh M. Alnaeli alnaelis@uwstout.edu 5,000.11 1333333 Bill Bultman Bill.bultman@uwc.edu 120,000.00 |
Account Number : 1333333 Name : Bill Bultman Email :Bill.bultman@uwc.edu Balance :120,000.00 ————————————- Account Number : 1201077 Name : Jonathan I. Maletic Email :jmaletic@ksu.edu Balance :10,000.17 ————————————- Account Number : 1991999 Name : Saleh M. Alnaeli Email :alnaelis@uwstout.edu Balance : 5,000.11 ————————————- |
Please make sure the code creates a customers.txt file andeverything runs smoothly.
Expert Answer
Answer to Write a C++ program (use dynamic memory allocation) that reads N customer records from a text file (customers.txt) such …