My Computer Science 1 classes have spent the past two class periods developing two different algorithms for a “minimum grade calculator” assignment.

Our grades are broken up as follows:

- Semester 1 (S1) – 50% of Year
- Quarter 1 (Q1) – 45% of Semester 1
- Quarter 2 (Q2) – 45% of Semester 1
- Semester Exam 1 (SE1) – 10% of Semester 1

- Semester 2 (S2) – 50% of Year
- Quarter 3 (Q3) – 45% of Semester 2
- Quarter 4 (Q4) – 45% of Semester 2
- Semester Exam 2 (SE2) – 10% of Semester 2

The assignment was to develop a program that would let students know the minimum needed grade(s) for the remaining grading periods to pass for both the semester and for the year. As part of this project, the only remaining grades are Q4 and SE2. This is 55% of the semester and 27.5% of the year.

We started by spending two days in algorithm development. The play had been for one day, but you’ll see why it took us two days.

#### Algorithm – Minimum for Semester

We started with development of a minimum grade for the semester. So, we started with this:

s2 = ( ( q3 * 2 ) + ( q4 * 2 ) + se2 ) / 5

We then condensed it to the following:

s2 = ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5

The “MIN” is the minimum grade that is needed for the 3/5 of the average that is still outstanding. We then moved to isolate the “MIN” variable as follows:

s2 = ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 ( 5 * s2 ) = ( q3 * 2 ) + ( MIN * 3 ) ( 5 * s2 ) - ( q3 * 2 ) = MIN * 3 ( ( 5 * s2 ) - ( q3 * 2 ) ) / 3 = MIN

We verified the algorithm against an established dataset and it checked.

#### Algorithm – Minimum for Year (Take 1)

The minimum for the year algorithm was the one that gave us a problem. We got it developed by the end of the first day, but it failed testing. You’ll see why, but we didn’t get a chance to correct it until the next class.

We started with the following:

y = ( s1 + s2 ) / 2

We then expanded it to the following:

y = ( s1 + ( ( ( q3 * 2 ) + ( q4 * 2 ) + se2 ) / 5 ) ) / 2

Like earlier, we consolidated the 6/10 of the year average (3/5 of the semester 2 average) as follows:

y = ( s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 ) ) / 2

The “MIN” is the minimum grade that is needed for the 3/5 of the semester average that is still outstanding. We then moved to isolate the “MIN” variable as follows: (NOTE: This is where our error occurred).

y = ( s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 ) ) / 2 2 * y = s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 ) ( 10 * y ) = s1 + ( q3 * 2 ) + ( MIN * 3 ) ( 10 * y ) - s1 = ( q3 * 2 ) + ( MIN * 3 ) ( 10 * y ) - s1 - ( q3 * 2 ) = ( MIN * 3 ) ( ( 10 * y ) - s1 - ( q3 * 2 ) ) / 3 = MIN

When we verified this against the dataset, it failed the tests. Regretfully, we ran out of time to correct it, so we had to push the correction to the next class period.

#### Algorithm – Minimum for Year (Take 2)

We verified the original algorithm once again and determined that it was wrong and would result in a logic error if used.

We analyzed the notes:

y = ( s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 ) ) / 2 ( 2 * y ) = s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 ) ( 10 * y ) = s1 + ( q3 * 2 ) + ( MIN * 3 ) ( 10 * y ) - s1 = ( q3 * 2 ) + ( MIN * 3 ) ( 10 * y ) - s1 - ( q3 * 2 ) = ( MIN * 3 ) ( ( 10 * y ) - s1 - ( q3 * 2 ) ) / 3 = MIN

We discovered that the error occurred at line 3. So, we adjusted the algorithm as follows:

y = ( s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 ) ) / 2 ( 2 * y ) = s1 + ( ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 ) ( ( 2 * y ) - s1 ) = ( ( q3 * 2 ) + ( MIN * 3 ) ) / 5 ( 5 * ( ( 2 * y ) - s1 ) ) = ( q3 * 2 ) + ( MIN * 3 ) ( ( 5 * ( ( 2 * y ) - s1 ) ) - ( q3 * 2 ) ) = MIN * 3 ( ( 5 * ( ( 2 * y ) - s1 ) ) - ( q3 * 2 ) ) / 3 = MIN

We verified the algorithm against an established dataset and it checked.

## One thought on “Grade Calculator Algorithm Development”