Skip to content
ExamSpine

Lesson 2.10 · Write it

Grade report

A whole programPython or Java8 tests, 4 of them hidden

On a phone? Put the lines in order instead

Write a program that reads a mark (whole number) on the first line and an absence flag on the second line, and prints a grade report.

  1. Always print Mark: followed by the mark on the first line.
  2. If the absence flag is exactly yes, print Absent on the next line. Nothing else about the mark matters.
  3. Otherwise, if the mark is 80 or above, print Distinction.
  4. Otherwise, if the mark is 50 or above, print Pass.
  5. Otherwise, print Fail.
  6. Print exactly one of those four result lines. Spaces at the end of a line are ignored.

The mark is always a whole number between 0 and 100. The absence flag is always yes or no.

Your program is run several times. Only what it prints is checked.

Running Java here comes later. You can put this answer's lines in order instead. You can still write your Java answer (it stays while this page is open) and compare it with our worked solution. Or try this exercise in Python.

Examples

Your program is run 8 times: the 4 examples below, and 4 hidden ones that check the rules above. Only what it prints is checked.

  • exactly 80 is Distinction, the boundary (rule 3)

    You type

    1. typed: 80
    2. typed: no

    It prints

    Mark: 80
    Distinction
  • a low mark, not absent (rule 5)

    You type

    1. typed: 45
    2. typed: no

    It prints

    Mark: 45
    Fail
  • absent overrides the mark (rule 2)

    You type

    1. typed: 70
    2. typed: yes

    It prints

    Mark: 70
    Absent
  • absent with a high mark still prints Absent (rule 2)

    You type

    1. typed: 90
    2. typed: yes

    It prints

    Mark: 90
    Absent
solution.pySolution.java