AQA · GCSE · Computer Science · Higher
C# conditional mark calculation
A university is writing a program to calculate a student's total mark for three essays. If any essays are handed in late, the total mark is reduced. Assume there are three integer variables called e1, e2 and e3 which have already been given values to represent the marks of the three essays.
Write a C# program to calculate the total mark. The program should: get the user to enter the number of essays handed in late and store it; calculate the total of e1, e2 and e3; reduce the total by 10 if only one essay is late; halve the total if more than one essay is late; ensure the total is not less than 0; and output the total mark. Use meaningful variable name(s) and C# syntax.
Write your answer first. You can study the marking guidance whenever you need it.
Study the marking See what earns credit and compare it with a full-mark answer.
Marking points
- 1 Uses meaningful variable names.
- 2 Uses selection to protect the lower bound of zero.
- 3 Reads and stores a numeric late-essay count.
- 4 Sums all three essay marks and applies the required reduction.
- 5 Correctly distinguishes one late essay from more than one.
- 6 Ensures the final total cannot be negative.
- 7 Outputs the final total after all calculations.
Full-mark answer
int lateCount = Convert.ToInt32(Console.ReadLine()); int total = e1 + e2 + e3; if (lateCount == 1) { total = total - 10; } if (lateCount > 1) { total = total / 2; } if (total < 0) { total = 0; } Console.WriteLine(total);
Why this answer loses marks
I totalled the essay marks, applied one late penalty and then printed the result.
The program must distinguish the late-count cases and cap a reduced total before the final output.