summaryrefslogtreecommitdiff
path: root/CST116-Ch11-Debugging-Pseudo-Code-Florea.txt
blob: 3e147c354ad0c6e5b25c7f28a0c7c88f7b3e0fdd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
init var EMPLOYEES as const integer, set it to 20
init var MAX as const integer, set it to 21

prototype func ReadData(inFile, Outfile, name[][MAX], age)
prototype func WriteOutPutFile(outfile, name[][MAX], age[], counter)
prototype func PrintTotalAndSummary(out, totalRecords)

def func main
    init var name as char as 2D array
    init var age as int array
    init var record_counter(0) as int

    init var inFile as ifstream (reading a file)

    init var ofstream as outFile (writing to file)

    if inFile is open
        record_counter = ReadData(inFile, outFile, name, age)
        close inFile

        if outFile is open
            WriteOutPutFile(outFile, name, age, record_counter)
            PrintTotalAndSummary(outFile, record_counter)
            close outFile
        
        else
            display "Trouble opening output file"
            display "About to exit NOW"

    else
        display "Trouble opening input file"
        display "About to exit NOW"

def func int ReadData(ifstream& inFile, ofstream& outFile,
                char name[][MAX], int age[])
    init var counter and set it to 0
    prime reading of inFile

    while line pointer not at the end of file of inFile
        read the input
        increase counter by 1
        read the name[counter] and age[counter]

    return counter

def func void WriteOutPutFile(ofstream& outFile, char name[][MAX], int age[], int counter)
    display "Here is the output file"

    for (var r set to 0; r is less than counter; add 1 to r)
        write input to outFile

def func void PrintTotalAndSummary(ofstream& outFile, int totalRecords)
    display "Total records" + totalRecords - to console screen
    display "Total records" + totalRecords - to output file