Loading lessons...
Project: Grade Calculator
Project 2: Grade Calculator
Read scores, compute an average, and show a letter.
Outline
- Ask how many scores.
- Loop and sum them.
- Compute average.
- Map to a letter:
if (avg >= 90) printf("A");
else if (avg >= 80) printf("B");
else if (avg >= 70) printf("C");
else printf("F");
Pseudocode
score total = 0
for i in 1..count:
total += input
avg = total / count
pick letter from avg
Extend
- Handle 0 scores.
- Also print the average.
- Support decimals with %f.
TL;DR
- Accumulate in a loop.
- Divide to average.
- Chain else-if buckets for the letter.