Level 6 — Programming — Jul/Aug 2024 — Practical

Level 6 • July/August 2024 • Practical assessment

Work through each question before checking the answer. These revision answers are prepared for learners; they are not an official marking scheme.

Question 1

Task1: Develop the Grade3 pupil-report system for30 pupils,5 subjects and3 assessments. Each score is0–100; average each subject and apply the supplied bands.

Answer

Save as PupilReport.java.

import java.util.Scanner;
public class PupilReport {
    static final String[] SUBJECTS = {
        "Mathematical Activities", "Language", "Kiswahili",
        "Environmental Activities", "Creative Activities"
    };
    static final String[] TESTS = {"Opener", "Midterm", "End term"};
    static double readMark(Scanner in, String prompt) {
        while (true) {
            System.out.print(prompt);
            try {
                double mark = Double.parseDouble(in.nextLine());
                if (Double.isFinite(mark) && mark >= 0 && mark <= 100) return mark;
            } catch (NumberFormatException ex) { }
            System.out.println("Enter a number from 0 to 100.");
        }
    }
    static String grade(double average) {
        if (average < 40) return "Below Expectation";
        if (average < 50) return "Approaches Expectation";
        if (average < 70) return "Meets Expectation";
        return "Exceeds Expectation";
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] names = new String[30];
        double[][][] marks = new double[30][5][3];
        for (int pupil = 0; pupil < names.length; pupil++) {
            do {
                System.out.print("Pupil " + (pupil + 1) + " name: ");
                names[pupil] = in.nextLine().trim();
            } while (names[pupil].isEmpty());
            for (int subject = 0; subject < SUBJECTS.length; subject++) {
                for (int test = 0; test < TESTS.length; test++) {
                    marks[pupil][subject][test] =
                        readMark(in, SUBJECTS[subject] + " - " + TESTS[test] + ": ");
                }
            }
        }
        for (int pupil = 0; pupil < names.length; pupil++) {
            System.out.println("\nTERM REPORT: " + names[pupil]);
            System.out.println("Subject | Opener | Midterm | End term | Average | Grade");
            for (int subject = 0; subject < SUBJECTS.length; subject++) {
                double total = 0;
                for (double mark : marks[pupil][subject]) total += mark;
                double average = total / TESTS.length;
                System.out.printf("%s | %.2f | %.2f | %.2f | %.2f | %s%n",
                    SUBJECTS[subject], marks[pupil][subject][0],
                    marks[pupil][subject][1], marks[pupil][subject][2],
                    average, grade(average));
            }
        }
    }
}

For fractional averages, use continuous bands [0,40), [40,50), [50,70), [70,100]; this extends the paper’s integer bands without leaving decimal gaps.

Step-by-step calculation

  1. Example for one subject: opener60, midterm70, end-term80.
  2. Total=60+70+80=210; average=210/3=70.
  3. 70 is in the70–100 band: Exceeds Expectation.
Test Expected result
Marks0,39,40,49,50,69,70,100 Each boundary maps to the stated band
Mark below0 or above100 Rejected and re-entered
30 pupils ×5 subjects ×3 scores 450 scores captured;30 reports printed

Question 2

Task2: Show the system flowchart and design requirements.

Answer

Pupil report flow: capture pupil and three scores for each subject, validate, average and grade, repeat for all subjects/pupils and print reports.
Pupil report flow: capture pupil and three scores for each subject, validate, average and grade, repeat for all subjects/pupils and print reports.
  1. Start; define subjects, assessments and30-pupil storage.
  2. For each pupil, capture a non-empty name.
  3. For each of five subjects, read and validate three scores.
  4. Calculate that subject’s average and determine its band.
  5. Repeat until all subject/pupil data are captured; output a report for every pupil.
  6. End.

The data design is names[30] and marks[30][5][3]. Validation is0–100, and the report shows all three assessments, the subject mean and grade. The supplied exercise gives no requirement for login, online storage or PDF reports.