📚 Year 9 CAIE Computer Science: Case Study Practice | Year 9 CAIE 计算机:案例分析实战演练
Case study exercises are a core part of the CAIE Computer Science curriculum for Year 9. They challenge you to apply problem-solving skills, design algorithms, and test solutions in a realistic context. In this walkthrough, we will tackle a practical scenario step by step, from analysing requirements to evaluating the final program. You will learn how to structure your thinking and present clear, logical solutions just as examiners expect.
案例分析练习是 Year 9 CAIE 计算机科学课程的核心部分。它要求你在真实情境中运用问题解决能力、设计算法并测试方案。在本次实战演练中,我们将逐步攻克一个实际场景,从分析需求到评估最终程序。你将学会如何组织思路,并按照阅卷老师期望的方式呈现清晰、逻辑严谨的解答。
1. Understanding the Case Study Scenario | 理解案例场景
Our case study involves a secondary school that wants a simple program to calculate the average mark of three subjects for each student and output a grade based on the average. The school needs a reliable, easy-to-use solution that works for any set of marks between 0 and 100.
我们的案例是:一所中学想要一个简单的程序,能够计算每位学生三科成绩的平均分,并根据平均分输出等级。学校需要一个可靠且易用的方案,能够处理任何 0 到 100 之间的成绩组合。
The program should prompt the user to enter the student's name and three marks. It must then compute the average, determine a grade (A for 80–100, B for 60–79, C for 40–59, D for 20–39, and E for 0–19), and display a message such as "Alex, your grade is B". The solution must handle invalid inputs gracefully.
该程序应提示用户输入学生姓名和三科成绩。然后计算平均分,判定等级(80–100 为 A,60–79 为 B,40–59 为 C,20–39 为 D,0–19 为 E),并显示如 "Alex, your grade is B" 的消息。解决方案必须能够妥善处理无效输入。
2. Defining Requirements | 明确需求
Before writing any code, we must identify the functional and non‑functional requirements. Functional requirements describe what the system should do, while non‑functional requirements describe how the system should perform.
在编写任何代码之前,我们必须明确功能需求和非功能需求。功能需求描述系统应该做什么,而非功能需求描述系统应如何运行。
Functional Requirements:
功能需求:
- Accept a student name as a string.
- 接受字符串类型的学生姓名。
- Accept three subject marks as integers between 0 and 100.
- 接受三个 0 到 100 之间的整数作为学科成绩。
- Calculate the average of the three marks.
- 计算三科成绩的平均分。
- Round the average to one decimal place.
- 将平均分四舍五入保留一位小数。
- Determine a grade based on the average.
- 根据平均分判定等级。
- Output the student’s name and grade.
- 输出学生姓名和等级。
Non‑Functional Requirements:
非功能需求:
- The interface should be simple and command‑line based.
- 界面应简单,基于命令行。
- Input validation must reject marks outside 0–100 and non‑numeric entries.
- 输入验证必须拒绝超出 0–100 的成绩以及非数字输入。
- The program should be efficient and run without unnecessary delays.
- 程序应高效运行,无不必要的延迟。
- Code should be well‑commented and easy to maintain.
- 代码应有良好注释且易于维护。
3. Designing the Solution: Algorithm and Flowchart | 设计方案:算法与流程图
A clear design is essential. We can represent the logic using a flowchart before coding. The main steps are: start, input name and marks, validate inputs, calculate average, decide grade, output result, stop. Below is a text‑based description of the flowchart.
清晰的设计至关重要。我们可以先用流程图表示逻辑,然后再编码。主要步骤为:开始,输入姓名和成绩,验证输入,计算平均分,判定等级,输出结果,结束。以下是流程图的文字描述。
Start → Input name → Input mark1, mark2, mark3 → Validate each mark (0– 3 → Round to 1 decimal place → Determine grade using ranges → Output name and grade → Stop
开始 → 输入姓名 → 输入三个成绩 → 验证每个成绩 (0–100) → 若无效 → 显示错误 → 返回重新输入 → 否则 → 平均分 = (成绩1+成绩2+成绩3)/3 → 四舍五入到一位小数 → 根据范围判定等级 → 输出姓名和等级 → 结束
Using standard flowchart symbols: an oval for Start/Stop, a parallelogram for Input/Output, a diamond for Decision, and a rectangle for Process. This logical sequence helps avoid missing steps.
使用标准的流程图符号:椭圆形表示开始/结束,平行四边形表示输入/输出,菱形表示判断,矩形表示处理。这种逻辑顺序有助于避免遗漏步骤。
4. Writing Pseudocode | 编写伪代码
Pseudocode bridges the gap between the design and actual code. It uses structured English and is not tied to any specific programming language. Below is the pseudocode for our student grade calculator.
伪代码是设计与实际代码之间的桥梁。
Published by TutorHao | Year 9 Computer Science Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)

或截图后用「扫一扫 → 相册」选择本图