The syllabus rule for late submissions in StudyBuddy's "deadline" feature is:
- submitted on time (0 days late or earlier) → full score;
- 1 to 7 days late → lose 10% of the score per day late;
- more than 7 days late → 0;
- the result is rounded to the nearest integer (halves up), and never negative.
An AI assistant produced this method:
static int f(int s, int d) {
int r = s;
if (d > 0) r = s - s / 10 * d; // 10% per day
if (d >= 7) r = 0;
return r;
}
It has two bugs (look closely at integer division and at the boundary) and several smells. Write a clean, correct program.
Input: lines score daysLate until the end of input (score 0–100 integer, daysLate any integer). For each, print score=S late=D -> R. At the end print Checked n submissions.
Input:
85 0
85 1
85 7
85 8
100 3
67 2
Output:
score=85 late=0 -> 85
score=85 late=1 -> 77
score=85 late=7 -> 26
score=85 late=8 -> 0
score=100 late=3 -> 70
score=67 late=2 -> 54
Checked 6 submissions
(For 85 and 1 day: 85 × 0.9 = 76.5 → 77. The AI version gives 77 only by luck: 85 / 10 * 1 = 8.)