← 返回资讯屏轩教育 · 行业资讯

Year 10 CAIE Computer Science: Case Study Hands-on Practice | IGCSE计算机案例分析实战演练

2026-07-20 22:25 · 本文部分内容由AI辅助创作

📚 Year 10 CAIE Computer Science: Case Study Hands-on Practice | IGCSE计算机案例分析实战演练

Case study questions are a core component of the CAIE IGCSE Computer Science Paper 2 (Problem-solving and Programming). They demand more than just recalling facts; you must apply algorithmic thinking, logic, and structured problem-solving to a given scenario. This article provides a complete walkthrough, from understanding the problem to testing the solution, using a realistic shopping discount example. Use this hands-on guide to build confidence and master the skills examiners look for.

案例分析题是 CAIE IGCSE 计算机科学 Paper 2(问题解决与编程)的核心组成部分。这类题目不仅需要记忆知识点,更要求你根据给定场景,运用算法思维、逻辑分析和结构化的问题解决方法。本文将提供一个完整的演练,从理解问题到测试解决方案,使用一个贴近实际的购物折扣场景。希望通过这份实战指南,帮你建立信心,掌握考官看重的技能。

1. What Are Case Study Questions? | 什么是案例分析题?

In the CAIE IGCSE Computer Science exam, a case study presents a real-world scenario with a set of tasks. You might be asked to complete a trace table, correct errors in pseudocode, draw a flowchart, or write your own algorithm. These questions assess how well you can decompose a problem, design a solution, and verify its correctness. Marks are awarded for logic, structure, and the appropriate use of programming constructs, not for memorising theory.

在 CAIE IGCSE 计算机科学考试中,案例分析题会给出一个现实世界的场景和一系列任务。你可能会被要求完成跟踪表、纠正伪代码中的错误、绘制流程图,或者编写自己的算法。这类题目考查你是否能将问题分解、设计解决方案并验证其正确性。评分依据是逻辑性、结构以及是否正确使用编程结构,而非死记硬背理论。

2. Understanding the Problem Statement | 理解问题陈述

Before writing any code, read the scenario carefully. Identify exactly what the program should do. For our example: "An online store wants a program to calculate the final price of an item after applying a discount. If the original price is greater than 200 units, a 20% discount is given. If it is greater than 100 but not more than 200, a 10% discount is given. Otherwise, no discount is applied. Display the final price." Highlight the keywords: input (original price), conditions (price > 200, price > 100), output (final price).

在编写任何代码之前,请仔细阅读题干。准确弄清程序应该做什么。以我们的示例为例:“一家网店需要一个程序,计算商品使用折扣后的最终价格。如果原价高于 200 单位,则给予 20% 的折扣。如果高于 100 但不超过 200,则给予 10% 的折扣。否则,不适用折扣。显示最终价格。” 标注出关键词:输入(原价)、条件(价格 > 200、价格 > 100)、输出(最终价格)。

Notice how the conditions overlap: the higher discount must be checked first. This is a common pitfall. Also, identify the data type: prices will likely be real numbers (floats). The output should be clear and maybe rounded to two decimal places. By extracting these details early, you reduce the chance of making a logic mistake later.

注意条件是如何重叠的:较高的折扣必须首先检查。这是一个常见的陷阱。同时,确定数据类型:价格很可能是实数(浮点数)。输出应清晰,可能四舍五入到两位小数。提前提取这些细节,可以降低后续犯逻辑错误的几率。

3. Identifying Inputs, Processes, and Outputs | 识别输入、处理和输出

The "IPO" model helps structure your thinking. For the discount problem:

“IPO”模型有助于构建你的思维。针对折扣问题:

Always define the variables you will need. In this case, we need variables for originalPrice, discount (a decimal like 0.2 or 0.1), and finalPrice. IGCSE pseudocode does not normally require variable declarations, but you must initialise them properly in your algorithm to avoid undefined values.

始终定义你需要的变量。在本例中,我们需要变量 originalPrice、discount(如 0.2 或 0.1 这样的小数)和 finalPrice。IGCSE 伪代码通常不要求变量声明,但你必须在算法中正确初始化它们,以避免未定义的值。


4. Designing the Algorithm with Pseudocode | 用伪代码设计算法

CAIE expects pseudocode that follows a specific style. Use keywords in uppercase (INPUT, OUTPUT, IF, THEN, ELSE, ENDIF, WHILE, DO, ENDWHILE, FOR, NEXT). Indent blocks clearly. Here is a correct algorithm for the discount scenario:

CAIE 要求遵循特定风格的伪代码。使用大写关键字(INPUT, OUTPUT, IF, THEN, ELSE, ENDIF, WHILE, DO, ENDWHILE, FOR, NEXT)。清晰地缩进代码块。以下是折扣场景的正确算法:

INPUT originalPrice
IF originalPrice > 200 THEN
    discount ← 0.2
ELSE IF originalPrice > 100 THEN
    discount ← 0.1
ELSE
    discount ← 0
ENDIF
finalPrice ← originalPrice * (1 - discount)
OUTPUT finalPrice

> 200 before > 100 ensures that a price of 250 will not mistakenly fall into the 10% structure, so no prior declaration is needed. The variable assignment uses the left arrow ← (Unicode character or simply '=' in some exam contexts; using ← is safer).

注意条件的顺序:先检查 > 200 再检查 > 100,可以确保 250 这样的价格不会错误地掉入 10% 那一档。此外,discount 通过选择结构初始化,因此不需要预先声明。变量赋值使用左箭头 ←(在考试中也可以使用 '=',但用 ← 更安全)。

If you are asked to refine the solution, consider validating the input so that negative prices are rejected. This could be done with a WHILE loop that prompts the user again until a valid price is entered. Always consider robustness.

如果要求优化解决方案,可以考虑验证输入,拒绝负价格。这可以通过 WHILE 循环实现,不断提示用户直到输入有效价格。始终考虑程序的健壮性。


5. Drawing a Flowchart | 绘制流程图

Flowcharts give a visual overview of the algorithm. CAIE requires you to use standard symbols: oval for Start/Stop, parallelogram for Input/Output, rectangle for process, and diamond for decision. The flow is shown with arrows. For our discount problem, the flowchart would look like this:

流程图可以直观地展示算法。CAIE 要求使用标准符号:椭圆形表示开始/结束,平行四边形表示输入/输出,矩形表示处理,菱形表示判断。流程用箭头表示。针对我们的折扣问题,流程图如下:

       Start
          ↓
   INPUT originalPrice
          ↓
   originalPrice > 200?
     /         \
    Yes        No
     ↓          ↓
 discount←0.2  originalPrice > 100?
     |          /         \
     |        Yes        No
     |         ↓          ↓
     |   discount←0.1  discount←0
     |          \        /
     |           \      /
     +--------->  finalPrice = originalPrice * (1 - discount)
                          ↓
                    OUTPUT finalPrice
                          ↓
                        Stop

In the exam, you would draw this neatly. The key is to ensure every decision has two branches (Yes/No) and that all paths merge correctly before the output. Practice drawing and converting between pseudocode and flowcharts, as this is a frequent question type.

考试中你需要清晰地画出这张图。关键是确保每个判断都有两个分支(是/否),并且所有路径在输出前正确汇合。多练习绘制并在伪代码和流程图之间转换,因为这是常见题型。


6. Using Trace Tables for Verification | 使用跟踪表进行验证

ing that your logic is correct. Suppose originalPrice = 250. We walk through line by line:

跟踪表展示了单步执行算法时变量值的变化。这是进行干运行和证明逻辑正确的最佳工具。假设 originalPrice = 250,我们逐行执行:

Line originalPrice discount finalPrice Condition
1 250 - -
2 250 - - 250 > 200? TRUE
3 250 0.2 -
6 250 0.2 200.0
7 250 0.2 200.0 Output 200.0

actice with different values (e.g., 150 gives discount=0.1, finalPrice=135.0) to spot logic errors early.

考试要求你完成部分填写的跟踪表。仔细填写每一列,并按照条件确定的精确路径执行。用不同的值(例如 150 得到 discount=0.1、finalPrice=135.0)进行练习,以便尽早发现逻辑错误。


广告 / Sponsored

7. Selecting Appropriate Test Data | 选择合适的测试数据

To demonstrate that your solution works, you must choose test data that covers all paths. In CAIE, you will often be asked to suggest three categories of test data: normal, boundary, and erroneous/exceptional. For our price program:

为了证明你的解决方案有效,你必须选择覆盖所有路径的测试数据。在 CAIE 中,你经常会被要求提出三类测试数据:正常、边界和错误/异常。针对我们的价格程序:

Type originalPrice Expected finalPrice Reason
Normal 50 50.00 Below both thresholds, no discount.
Normal 120 108.00 Between 100 and 200, 10% discount.
Normal 300 240.00 Above 200, 20% discount.
Boundary 100.01 90.00 (approx) Just above 100, check 10% applies.
Boundary 200 180.00 Exactly 200 - still 10%, not 20%, because condition is >200.
Boundary 200.01 160.01 Just over 200, now 20%.
Erroneous -20 Error message Invalid price, should be rejected. Requires input validation.

In the exam, justify why each test value is chosen. Boundary testing is crucial: test values just below, exactly at, and just above each threshold. Also include extreme values like 0 and very large numbers for thoroughness.

考试中要解释为什么选择每个测试值。边界测试至关重要:测试刚好低于、恰好等于和刚好高于每个阈值的数值。为了全面起见,还应包括 0 和极大值等极端数据。


8. Identifying and Fixing Errors | 识别并修复错误

Examiners often provide a faulty algorithm and ask you to identify the mistake. Consider this incorrect pseudocode for the same problem:

考官经常提供一个有问题的算法,让你找出错误。以下是有同样问题的错误伪代码:

INPUT originalPrice
IF originalPrice > 100 THEN
    discount ← 0.1
ELSE IF originalPrice > 200 THEN
    discount ← 0.2
ELSE
    discount ← 0
ENDIF
finalPrice ← originalPrice * (1 - discount)
OUTPUT finalPrice

Can you spot the error? If originalPrice is 250, the first IF condition (originalPrice > 100) is TRUE, so it sets discount to 0.1 and skips the ELSE IF. The customer receives only a 10% discount when they should get 20%. The fix is to swap the conditions: check > 200 first, as shown in Section 4.

你能发现错误吗?如果 originalPrice 是 250,第一个 IF 条件 (originalPrice > 100) 为 TRUE,因此将 discount 设为 0.1 并跳过 ELSE IF。顾客本该享受 20% 的折扣,却只得到了 10%。修复方法是交换条件:先检查 > 200,就像第 4 节所示的那样。

Another common error is forgetting to initialise discount before the selection statement. In some languages this would cause an error; in IGCSE pseudocode, it may lead to an undefined value being used in the calculation. Always ensure every variable has a value before it is read.

另一个常见错误是忘记在选择语句之前初始化 discount。在某些语言中这会导致错误;在 IGCSE 伪代码中,可能导致计算时使用未定义的值。始终确保每个变量在被读取之前都有一个值。


9. Translating to Program Code (Conceptual) | 转换为程序代码(概念性)

Although Paper 2 focuses on pseudocode and flowcharts, understanding how your algorithm maps to real Python or Java code can deepen your grasp. In Python, the same discount logic would look like:

尽管 Paper 2 侧重于伪代码和流程图,但理解如何将算法映射到真实的 Python 或 Java 代码,可以加深你的理解。在 Python 中,同样的折扣逻辑如下:

price = float(input("Enter original price: "))
if price > 200:
    discount = 0.2
elif price > 100:
    discount = 0.1
else:
    discount = 0
final = price * (1 - discount)
print("Final price:", round(final, 2))

This demonstrates the direct relationship between pseudocode keywords and real code constructs. In the exam, you will not write code in a specific programming language, but visualising the translation helps reinforce the logical flow and aids in debugging.

这展示了伪代码关键字与实际代码结构之间的直接关系。考试中你不需要用特定的编程语言编写代码,但想象这种转换有助于强化逻辑流程,并帮助调试。

Note that Python uses 'elif' instead of ELSE IF, and assignment uses '=' not '←' ical details that are often assumed in pseudocode but must be explicit in a real language.

注意 Python 使用 'elif' 而非 ELSE IF,赋值使用 '=' 而不是 '←'。四舍五入和输入类型转换是实际细节,在伪代码中通常被省略,但在真实语言中必须明确写出。


10. Summary and Exam Tips | 总结与考试技巧

Case study questions reward a methodical approach. Remember these tips: (1) Read the scenario and underline the key requirements. (2) Plan your variables and IPO before writing. (3) Use standard CAIE pseudocode conventions. (4) Test with a trace table using at least three different values. (5) Choose test data that covers boundary and error cases. (6) Review your logic for overlapping conditions. By practising with many sample scenarios, you will be able to tackle any case study with confidence.

案例分析题青睐有条理的方法。记住这些技巧:(1) 阅读场景并在关键要求下划线。(2) 在编写之前规划变量和 IPO。(3) 使用标准的 CAIE 伪代码规范。(4) 使用至少三个不同的值,借助跟踪表进行测试。(5) 选择涵盖边界和错误情况的测试数据。(6) 检查逻辑中的条件重叠问题。通过大量练习各种示例场景,你就能自信地应对任何案例分析题。

Time management is essential: allocate time to think before coding, and always leave a few minutes to check your trace table and test data. Good luck with your IGCSE Computer Science journey!

时间管理至关重要:留出时间在编程前思考,并始终留几分钟检查你的跟踪表和测试数据。祝你的 IGCSE 计算机科学之旅好运!


Published by TutorHao | Computer Science Revision Series | aleveler.com

广告 / Sponsored
现货 Cambridge International AS & ALevel IT Coursebook剑桥国际IGC…
计算机 备考教辅 · 正版现货 · 与本文内容相关
查看详情 / View on Taobao参考价 ¥467.0

更多咨询请联系16621398022(同微信)

备考资讯每日更新,关注不错过
考纲变化 · 科目分析 · 学习方法
扫码关注公众号 tutorhao
在微信里长按二维码识别关注
或截图后用「扫一扫 → 相册」选择本图
公众号:tutorhao