I need a basic pseudocode for this instruction and please simplify this. The dat
ID: 3707426 • Letter: I
Question
I need a basic pseudocode for this instruction and please simplify this.
The data you will read in from the files will be information about charges in a given time period. Each line in the transaction file will contain the ClientID Number and the amount of charged to that client. Each line in the Master file will represent the current balance for the client. It also will have a ClientID and an amount which will represent the current balance before the processing of the transaction file. An example line from the transaction file might look like the following:
221B,447
An example line from the Master file will have the same format.
Note in the example above, the comma is the delimiter between data items so money values cannot have commas. ClientIDs will contain letters and numbers so a NUM data type will not be acceptable.
Using examples of various logics in the text, write the pseudocode that will integrate the transactions into the master file. The new merged (or updated file as the text calls it) is to have all the ClientIDs from the Master file updated along with any new accounts (new ClientIDs) found in the transaction file. A second New Accounts output file will need to be made and the ClientIDs of the new clients only will need to be placed into that file. ClientIDs will contain letters and numbers so a NUM data type will not be acceptable.
In the end, the updated file along with the new accounts file will have been created. If no new accounts were created, logic in the program should display a message in the New Accounts file that says no new accounts created. Both the Master file and the Transaction file will be considered to be sorted in ClientID order. A ClientID will not have duplicate entries in the transaction file. If there is a ClientID in the transaction file, there will only be one entry in that transaction file. These assumptions will make the coding very similar to examples in the text as those assumptions were also made in those examples.
Explanation / Answer
initialize transaction_ids as an empty array
open the transaction file in read mode
while there is a line present do,
set line equals to currrent read line
split the line into two parts using delimiter ,(COMMA)
add first part i.e. at index [0] of the splited values, to transaction_ids
close the transaction file
initialize master_ids as an empty array
open the master file in read mode
while there is a line present do,
set line equals to currrent read line
split the line into two parts using delimiter ,(COMMA)
add first part i.e. at index [0] of the splited values, to master_ids
initialize all_ids as an empty array
set all_ids as the conctenation of transaction_ids and master_ids arrays
sort the all_ids array
open a new file by name updated_merged_file in write mode
open a new file by name new_accounts_file in write mode
initialize empty as True
for each id in all_ids do,
add the id to the updated_merged_file
if id is not in master_ids
add the id to new_accounts_file
set empty as False
if empty is True
add "no new accounts created" to the new_accounts_file
close updated_merged_file
close new_accounts_file
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.