Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 2: An electricity company maintains its customer records in a sequential

ID: 3594657 • Letter: P

Question

Problem 2: An electricity company maintains its customer records in a sequential text file named accounts.txt. The record for each customer contains the following: account number, name, street address, city, state, zip, payment due, and days late. Design the logic, in pseudocode, for a program that

f. Reads each record in the accounts.txt file

g. Determines the late fee (if any) to be added for the account based on the following rules:

i. If the number of days payment is late is between 1 and 7, then the late fee is $5

ii. If the payment is between 8 and 14 days late, then the late fee is $10

iii. If the payment is more than 14 days late, then the late fee is $25

h. Calculates the payment due after adding the late fee

i. Writes the account data with the updated payment due amount to another file named processed_accounts.txt

j. In another file named statements.txt, writes the account data in the proper format for an account statement that has

i. the account holder’s name and address as required by the post office

ii. the account number

iii. the payment due before the late fee was added

iv. the number of days the payment is late by (include this and the next three items only if the payment is late by 1 or more days)

v. the late fee

vi. the payment due after adding the late fee

vii. if the payment is more than 14 days late, then, below the payment due after adding the late fee, include a warning that service will be disconnected in 7 days

Explanation / Answer

begin

               inputFile = 'accounts.txt'

               outputFile = 'processed_accounts.txt'

               bankStatementFile = 'statements.txt'

               // open the accounts.txt file for reading data line by line

               open inputFile in read mode

               // create processed_accounts.txt and statements.txt for writing output

               create new files outputFile and bankStatementFile in write mode

               // read the file till we reach its end

               while end of inputFile has not been reached

                              // Each line in inputFile contains account number, name, street address, city, state, zip, payment due, days late each separated by space i.e one record

                              read one line from inputFile into the variables accountNumber , name, streetAddress, city, state, zip, paymentDue, daysLate

                              //calculation of late fee

                              lateFee = 0

                              if(daysLate > 0 and daysLate <= 7) then

                                             lateFee = 5

                              else if(daysLate > 7 and daysLate <= 14) then

                                             lateFee = 10

                              else if(daysLate > 14) then

                                             lateFee = 25

                              // update the paymentDue

                              updated_paymentDue = paymentDue + lateFee

                              write accountNumber , name, streetAddress, city, state, zip , updated_paymentDue to outputFile

                              // streetAddress,city,state,zip - address

                              if(daysLate = 0) then

                                             write name, streetAddress, city, state, zip to bankStatementFile

                                             write accountNumber to bankStatementFile

                                             write paymentDue to bankStatementFile

                              else if(daysLate > 0) then

                                             write name, streetAddress, city, state, zip to bankStatementFile

                                             write accountNumber to bankStatementFile

                                             write paymentDue to bankStatementFile

                                             write daysLate to bankStatementFile

                                             write lateFee to bankStatementFile

                                             write updated_paymentDue to bankStatementFile

                                             if(daysLate > 14) then

                                                            write "Warning : Service will be disconnected in 7 days" to bankStatementFile

                              move to next line in inputFile // move to the next line to read the next record

               end while

               close inputFile,outputFile,bankStatementFile // close all the files

end       

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote