Past-paper question · 2024 May-June · Paper 42 · Q1(b)

Question 1(b) 2024 · May-June · Paper 42 · 4 marks

Original past-paper question for 1(B)
Original past-paper question for 1(B)
Reveal official mark-scheme answer Official mark-scheme answer for 1(B)

Official answer for Question 1

Part (b)

Question 1

mark each

Question 4

✓
Outputting message to ask user to enter easy, medium, hard
✓
Taking input from user
✓
Conversion of input to filename…
✓
… calling ReadWords() with correct filename in each case
✓
e.g.
✓
Java
✓
public static void main(String args[]){
✓
NumberWords = 0;
✓
Scanner scanner = new Scanner(System.in);
✓
System.out.println("Easy, medium or hard?");
✓
String Choice = scanner.nextLine();
✓
if(Choice.equals("Easy")){
✓
ReadWords("Easy.txt");
✓
}else if(Choice.equals("medium")){
✓
ReadWords("Medium.txt");
✓
}else{
✓
ReadWords("Hard.txt");
✓
}
✓
}
✓
VB.NET
✓
Sub Main(args As String())
✓
Console.WriteLine("Easy, medium or hard?")
✓
Dim FileName As String
✓
Dim Choice As String = Console.ReadLine().ToLower()
✓
If Choice = "easy" Then
✓
FileName = "Easy.txt"
✓
ElseIf Choice = "medium" Then
✓
FileName = "Medium.txt"
✓
Else
✓
9618/42
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2024
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_s24_ms_42.pdf →

Show text version of question

Question 1

Part (b)

Question 1

A program outputs a main word. The program asks the user to enter the different words of 3 or

more letters that can be made from the letters in the main word. These are called the answers.

There are 3 files: Easy.txt, Medium.txt and Hard.txt. Each file has the main word on the first line. For example, the main word in Easy.txt is house.

The answers are stored in the file. Each answer is on a new line after the main word. For example, Easy.txt has 14 answers that can be made from the letters in house.

The words read from the text file are stored in the global array WordArray. The number of words that can be made from the letters in the main word is stored in the global variable NumberWords.

Part (b)

The main program asks the user to enter "easy", "medium" or "hard" and calls

ReadWords()with the filename that matches the user’s input. For example, if the user enters "easy", the parameter is "Easy.txt".

Write program code for the main program.

Save your program.

Copy and paste the program code into part 1(b) in the evidence document.

[4]

Question 3

Topic relevance

Why this question appears here

75% assigned-topic match · Programming › Constructs

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9618_s24_qp_42.pdf

Keep practising this topic