My Design for Homework 3
Objectives
We would like to :
- Discuss a possible design for homework 3.
Notes
Main
Begin Processing
Process the grades for homework
Process the grades for groupwork
NOTE: Both of these have the same structure/routine
Process Grades for tests
Process Final Exam Grade
Process Class Average
Process Class Grade
Begin Processing
Input: None
Ouptut: Open File descriptor
Open the File
Read the name from the file
Print Name line
Process Grades
Input: The open file descriptor
The type of work (Homework, Groupwork), a string
Output: The final average, a float
A boolean flag, true if homework was present
set score to 0
set available to 0
from the file read in numerator, slash, denominator
while denominator is not zero
score += numerator
available += denominator
from the file read in numerator, slash, denominator
if denominator = 0
print not present line
valid = false
else
print average
valid = true
Process Tests
Input: The open file descriptor
Output: The test average
Boolean flag, true if tests were present
Read number of tests from file.
set average to be 0
for each test
read score from file
add score to average
if number of tests > 0
valid = true
average = average / number of tests
Print test average
else
valid = false
Print not present line
Process Final
Input: The open file descriptor
Output: The test average
A boolean flag, true if a final was present.
read the final flag from the file
if the final flag is y
read the final score from the file
valid = true
print the final line
else
print the not present line
valid = false
Process Class Average
Input: The open file descriptor
The homework average, flag
The groupwork average, flag
The test average, flag
The Final average, flag
Output : Class average
Valid, a boolean flag.
read in the weights
avaiable = 0
points = 0
Note: These are all the same, build a function to do this.
if the homework is valid
Add homework weight to available
Add homework average * homework weight to points
if the groupwork is valid
Add groupwork weight to available
Add homework average * groupwork weight to points
if the tests is valid
Add tests weight to available
Add tests average * tests weight to points
if the final is valid
Add final weight to available
Add final average * final weight to points
If avialable > 0
Compute class average: points/avilable
valid = true
Pint Class average line
else
valid = false
Print not present line.
Process Class Grade
Input: The open file descriptor
The class average
A boolean flag if average is valid
Output: None
if the average is valid
Read in the grade minimums from the file
If the average >= A limit
Print A
else if the average >= B limit
Print B
else if the average >= C limit
Print C
else if the average >= D limit
Print D
else
Print F
else
Print not present line