|
|
|
|
|
|
|
Open For Output (Inout: someFile) |
|
|
|
|
|
|
|
|
We can modify the Open For Input module so that it
opens an output file. |
|
|
|
|
|
|
|
|
|
Get Candidate Names (Out: name) |
|
|
|
|
|
|
|
|
|
Print Enter the names of the candidates, one per line,
in the order they appear on the ballot.
FOR candidate going from 0 through NUM_CANDIDATES - 1
Read name[candidate] |
|
|
|
|
|
|
|
|
|
|
Note that each candidate's name is stored in the slot in the name array corresponding to his or her candidate number (minus 1). These names are useful when the totals are printed. |
|
|
|
|
|
|
|
|
Set Votes to Zero (Out: votes) |
|
|
|
|
|
|
|
|
FOR each precinct
FOR each candidate
Set votes[precinct][candidate] = 0 |
|
|
|
|
|
|
|
|
|
Write Table (In: votes, name; Inout: reportFile) |
|
|
|
|
|
|
|
|
|
// Set up headings
FOR each candidate
Write name[candidate] to reportFile
Write newline to reportFile
// Print table by row
FOR each precinct
FOR each candidate
Write votes[precinct][candidate] to reportFile
Write newline to reportFile |
|
|
|
|
|
|
|