1. Engineering
2. Computer Science
3. problem 1 data processing 50 the owners of a corner...

# Question: problem 1 data processing 50 the owners of a corner...

###### Question details

Problem 1: Data Processing (50%)

The owners of a corner store in a rural area allow their customers from the village to purchase on credit any item in the store. When a purchase is done on credit, it is recorded in a file. The phone number of the family, the date of purchase and the amount due are recorded. Any member of a family in the village can come anytime and make a payment towards what is due, or even an advance. The phone number of the family, the date of the payment and the amount are recorded in a separate file. The owners noticed that some of the customers often still owe them a large amount at the end of the month. They decided to stop providing credit to families that owe them more than $500 at the end of the month and add interest of 1% to any family that owe them more than$100 at the end of the month.

You meet the owners of this store who ask you to assist them by writing a python program that would generate a report at the end of the month given three files as input.

The first file families.txt contains the list of known customers from the community. The file has their phone number, name of head of family and their address. The file has in each line a phone number, a full name and an address separated by ",”. The file content looks like this:

7804922860,Osmar Zaiane,32 Alphonse Street
7809876543,Farrukh Ahmed,101 Edson Crest
7803214567,Md Toukir Imam,34 Sherwood Park Avenue
7808907654,Rong Feng,32 Spruce Street
7801236789,Nazanin Tahmasebi,98 Albert Avenue
7809001234,Alfred Baali, 3 Tijani street
7808765432,Amir Hossein,45 Beautiful Street


The second file dues.txt, contains information about the purchases that were bought on credit. Each line contains a date, the amount due, and the phone number of the family who did the purchase, all separated by ";”. The date is formatted YYYY/MM/DD. The file looks like this.

2018/11/02;98.95;7808907654
2018/11/05;22.50;7801234567
2018/11/10;86.45;7807890123
2018/11/15;88.50;7807890123
2018/11/15;34.97;7804922860
2018/11/15;85.15;7809876543
2018/11/15;50.20;7801234567
2018/11/18;45.95;7804922860
2018/11/21;97.35;7804922860
2018/11/26;56.75;7803214567
2018/11/27;58.15;7809876543
2018/11/28;67.80;7801236789
2018/11/30;65.95;7801236789
2018/11/30;72.50;7801234567
2018/11/30;12.75;7804321098
2018/11/30;73.65;7801236789
2018/11/30;64.85;7807890123
2018/11/30;120.5;7808765432
2018/11/30;27.55;7804321098


The third file payments.txt, contains information about payments. Its structure is similar to the second file. Each line contains a date, the amount paid, and the phone number of the family who did the payment, all separated by ";”.:

You are required to write a program that would generate a file, call it summary.txt, that can be printed and contains a table listing the customers that purchased credit and that made payments with their total dues and the list of payments they did. The table should be formatted as follows and the list of payments with the dates should be outside the table on the right.

Your program should read the three files and produce a table formatted as follows:

+--------------+------------------+--------+-----+
| Phone Number | Name             | Due    | Int |
+--------------+------------------+--------+-----+
|(780) 123 4567|Robert Post       |$92.70| | |(780) 123 6789|Nazanin Tahmasebi |$  22.25|     | [$30.00] 2018/11/30 ($30.00);
|(780) 321 4567|Md Toukir Imam    |$84.75| | |(780) 432 1098|Sayem Mohammad |$  25.25|     | [$15.50] 2018/11/25 ($5.5); 2018/11/30 ($10.00); |(780) 492 2860|Osmar Zaiane |$  91.22|     |
|(780) 789 0123|Elham Ahmadi      |$111.30|$1.10| [$42.50] 2018/11/30 ($42.50);
|(780) 876 5432|Amir Hossein      |$148.47|$1.47|
|(780) 890 7654|Rong Feng         |$130.99|$1.29|
|(780) 900 1234|**Alfred Baali    |$517.22|$5.12|
|(780) 987 6543|Farrukh Ahmed     |$26.25| | [$50.00] 2018/11/30 ($50); +--------------+------------------+--------+-----+ | Total Dues |$    729.32|
+--------------+---------------------------+
| Total Interes|                  $3.86| +--------------+---------------------------+  The table has 4 columns and is sorted by the phone number. • The first column is the phone number. This number has to be formatted as (999) 999 9999. • The second column is the name and it has to be 18 characters wide. If the name is longer, the name is truncated to fit. In addition, the name is prefixed with "**" if the amount due is higher than$500.
• The third column is the amount due. This amount should be printed with 7 positions and only 2 after the decimal point. Note that the amount due should be increased by the interest if the initial amount is higher than \$100.
• The fourth column is the interest due which should be printed with 4 positions and only 2 after the decimal point. The interest should not be printed if equal to zero.
• Moreover, alongside the table and on the same row of the customer, we need to have the list of payments with the dates they were made formatted as per the example table. The list is preceded by the total paid between square brackets. All amounts should be formatted with 2 numbers after the decimal point.
• Finally, two lines at the end of the table should indicate the total amount due by the whole community and the total interest incurred by all the customers. The table should be formatted as illustrated above.

In addition to the output file, the same output should also appear on the screen.

Note that the example output table is not exactly related to the two input examples provided here. Indeed the output depends on 3 input files. The input provided here is just an example. You should create your own 3 files and stick to the structure described here. The TAs will evaluate your assignment with different input files.

Also note that the "Total Interest" is written without the "t". It is intentional. This is what the customer wants.