Past-paper question · 2019 October-November · Paper 41 · Q1(e)(vi)

Question 1(e)(vi) 2019 · October-November · Paper 41 · 8 marks

Question 1

Part (e)

(vi)

Question 1

Each student at CIE University needs a printing account to print documents from university

computers.

The university is developing software to manage each student’s printing account and the printing process. There are 1000 students at the university. They will each require a printing account.

Students need to buy printing credits that will be added to their account. Each page printed uses one printing credit.

The university needs software to keep track of the number of printing credits each student has in their account. The university has decided to implement the software using object-oriented programming (OOP).

The following diagram shows the design for the class PrintAccount. This includes the attributes and methods.

PrintAccount FirstName : STRING // parameter sent to Constructor() LastName : STRING // parameter sent to Constructor() PrintID : STRING // parameter sent to Constructor() Credits : INTEGER // initialised to 50 Constructor() // instantiates an object of the PrintAccount class, // and assigns initial values to the attributes GetName() // returns FirstName and LastName concatenated // with a space between them GetPrintID() // returns PrintID SetFirstName() // sets the FirstName for a student SetLastName() // sets the LastName for a student SetPrintID() // sets the PrintID for a student AddCredits() // increases the number of credits for a student RemoveCredits() // removes credits from a student account

Question 9

(vi)

The main program has a procedure, CreateID(), that:

  • takes the first name and last name as parameters
  • creates PrintID that is a concatenation of:

◦ the first three letters of the first name in lower case ◦ the first three letters of the last name in lower case ◦ the character ‘1’ for example, the name Bill Smith would produce "bilsmi1"

  • checks if the PrintID created already exists in the global array StudentAccounts:

◦ If PrintID does not exist, it creates an instance of PrintAccount in the next free index in StudentAccounts. ◦ If PrintID does exist, the number is incremented until a unique ID is created, for example, "bilsmi2". It then creates an instance of PrintAccount in the next free index in StudentAccounts.

The global variable NumberStudents stores the number of print accounts that have currently been created.

Write program code for the procedure CreateID(). Do not write the procedure header.

Programming language .....................................................................................................

Program code

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Question 13

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.....................................................................................................................................

[8]

Question 14

Reveal official mark-scheme answer Official mark-scheme answer for 1(E)(VI)Official mark-scheme answer for 1(E)(VI)

Official answer for Question 1

Part (e)

(vi)

Question 1

mark per bullet point to max 8

Question 8

✓
•
✓
Generating ID with ‘1’ at the end all in lowercase from parameters
✓
•
✓
Loop through array to last occupied element «
✓
•
✓
« Check if the PrintID already exists
✓
•
✓
« using GetPrintID()
✓
•
✓
« increment number at end of PrintID
✓
•
✓
Create a new instance of PrintAccount «
✓
•
✓
« sending FirstName, LastName, PrintID as parameters
✓
•
✓
adding new account to StudentAccounts at position NumberStudents
✓
•
✓
Increment NumberStudents
✓
VB.NET
✓
Sub CreateId(firstName, lastName)
✓
Dim count As Integer
✓
Dim PrintID = Left(firstname, 3).ToLower & Left(lastname, 3).ToLower & “1”
✓
Dim studentAdd As Integer = 0
✓
If numberStudents <> 0 Then
✓
For x = 0 To numberStudents - 1
✓
If studentAccounts(x).getPrintID() = username Then
✓
PrintID = PrintID + 1
✓
username = Left(firstname, 3).ToLower & Left(lastname, 3).ToLower &
✓
PrintID.ToString
✓
End If
✓
Next
✓
studentAdd = numberStudents
✓
End If
✓
studentAccounts(studentAdd) = New printAccount(firstname, lastname, username)
✓
numberStudents = numberStudents + 1
✓
9608/41
✓
Cambridge International AS/A Level – Mark Scheme
✓
October/November 2019
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w19_ms_41.pdf →

Topic relevance

Why this question appears here

98% assigned-topic match · Further programming › Programming paradigms

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 9608_w19_qp_41.pdf

Keep practising this topic