CS Scenario Questions by Sockette
CS Scenario Questions by Sockette
Before using the test, the user can set the times table to be tested and
the number of questions to be asked. The times tables can be any whole number between 2 and 12
inclusive. The number of questions can be between 5 and 10 inclusive. No questions can be the same in
any test. The name of the user should be displayed with all messages and prompts.
Write and test a program that meets the following requirements:
o Sets up the starting conditions for the test
o During the test:
o displays each question with the question number
o checks if the answer input is correct and displays the right answer if the answer input was
wrong
o adds one to the user’s total every time an answer is right.
o At the end of the test:
o displays the result
o asks the user if they want a retest.
You must use pseudocode or program code and add comments to explain how your code works. All
inputs and outputs must contain suitable messages.
14
13 The 1D array StudentName[] contains the names of students in a class. The 2D array
StudentMark[] contains the mark for each subject, for each student. The position of
each student’s data in the two arrays is the same, for example, the student in position 10 in
StudentName[] and StudentMark[] is the same.
The variable ClassSize contains the number of students in the class. The variable SubjectNo
contains the number of subjects studied. All students study the same number of subjects.
The arrays and variables have already been set up and the data stored.
You must use pseudocode or program code and add comments to explain how your code works.
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
...........................................................................................................................................................
15 Write and test a program that uses a two-dimensional array, Game[]to store the moves
in a noughts and crosses game. The program should meet the following requirements:
» Start each game with an empty array.
» Allow two players to input their moves in turn; the contents of the array are displayed
before and after every move.
» One player can input O and the other input X; no other moves are allowed, and no move
can use a space in the array already occupied.
» After every move the program should check for a completed line of three Os or three Xs,
and if found output the winner of the game.
» Use procedures and parameters.
» Include comments to explain how your code works.
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
.................................................................................................................................................................................
Photocopying prohibited
54 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
c)
[6]
11
Python:
# set up starting conditions
Name = input("Please enter your name ")
Table = 0
while (Table < 1 or Table > 12):
Table = int(input("Please enter a table between 1 and 12 "))
Questions = 0
while (Questions < 5 or Questions > 10):
Questions = int(input("Please enter the number of questions between 5 and 10 "))
Retest = True
[14]
Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 6
© Hodder & Stoughton Ltd 2022
Cambridge IGCSE™ and O Level Computer Science
Visual Basic:
Module Module1
Sub Main()
Dim Name, Choice As String
Dim Table, Questions, QuestionNumber, Right, Answer As Integer
Dim ReTest As Boolean
' set up staring conditions
Console.Write("Please enter your name ")
Name = Console.ReadLine()
Do
Console.Write("Please enter a table between 1 and 12 ")
Table = Int(Console.ReadLine())
Loop Until Table >= 1 And Table <= 12
Do
Console.Write("Please enter the number between 5 and 10 ")
Questions = Int(Console.ReadLine())
Loop Until Questions >= 5 And Questions <= 10
ReTest = True
[14]
Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 7
© Hodder & Stoughton Ltd 2022
Cambridge IGCSE™ and O Level Computer Science
Java:
import java.util.Scanner;
class ExamQ11Java
{
int Questions;
do
{
System.out.print("Please enter the number of questions between 5 and 10 ");
Questions = myObj.nextInt();
}
while (Questions < 5 || Questions > 12);
Cambridge IGCSE™ and O Level Computer Science Second Edition Study and Revision Guide 8
© Hodder & Stoughton Ltd 2022
0478/02 Cambridge IGCSE – Mark Scheme For examination
SPECIMEN from 2023
// meaningful identifier names and appropriate data structures (variables, constants and the
// given arrays) to store all the data required
DECLARE TotalMark : ARRAY[1:50] OF INTEGER
DECLARE AverageMark : ARRAY[1:50] OF INTEGER
DECLARE SubjectCounter : INTEGER
DECLARE StudentCounter : INTEGER
DECLARE DistinctionNo : INTEGER
DECLARE MeritNo : INTEGER
DECLARE PassNo : INTEGER
DECLARE FailNo : INTEGER
CONSTANT Distinction = 70
CONSTANT Merit = 55
CONSTANT Pass = 40
// initialisation processes for this scenario, initialising the running totals used for
// grades and combined totals
DistinctionNo ← 0
MeritNo ← 0
PassNo ← 0
FailNo ← 0
// programming techniques of iteration, selection, totalling, counting and output are used
You must:
- Calculate and store the total points scored
- Calculate and display the total points for all matches in
each category (away win, home win, draw, loss)
- Calculate and display the total team points, total team
points for each category and name for each of the teams
- Find and display the name of the team with the highest and
lowest points
[15]
(Unofficial Python Markscheme by S_Skamr ~ Past Paper hasn't been
released yet)
"""
MAPPINGS
0: Loss
1: Draw
2: Home Win
3: Away Win
They start with 0 so it can be easily used to index into a list that
stores every count for the mappings - helpers.
"""
# Maps each index to the required message when printing - for eg. an index
of 1 corresponds to the returned message "Draws" which can be used to
display the required details for draws
def mapMsg(index):
return ["Losses", "Draws", "Home wins", "Away wins"][index]
# Print the team with the lowest and highest points and their names
print(f"Lowest scoring team with {lowest[1]} points is {lowest[0]}.")
print(f"Highest scoring team with {highest[1]} points is {highest[0]}.")