blob: 3667291b71d9f5f1a931281af2089b331155802a (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
Troy 12
Jose 14
Aaron 21
** Total Records: 3 **
The End
//// OUTPUT FILE
Here is the Output File
Troy 12
Jose 14
Aaron 21
** Total Records: 3 **
The End
main(){
FLOWCHART
INITIALIZE inFile;
INITIALIZE AND OPEN outFile("report.txt");
OPEN inFile(data.txt);
IF inFile.is_open() == TRUE {
INT record_count = ReadData()
inFile.close();
if(outFile.is_open() == TRUE){
PrintReportToOutFile();
PrintTotalsAndSummary();
outFile.close();
}
else
{
PRINT "Trouble Opening File! Exiting Now";
}
}
else
{
PRINT "Trouble Opening File! Exiting Now";
}
ENDPROGRAM;
}
INT ReadData(ifstream inFile, ofstream outFile, char name[][MAX], int age[]){
INT counter = 0;
inFile >> name[counter] >> age[counter]; // Starts reading the arrays from the beginning
WHILE( !inFile.eof() ){ // While not at the end of the file
PRINT name[counter];
PRINT age[counter];
counter++;
inFile >> name[counter] >> age[counter]; // Starts reading the next items in the arrays
}
// Print the final entry
PRINT name[counter];
PRINT age[counter];
counter++;
RETURN counter;
}
|