Photo AI

A library gives each book a code made from the first three letters of the book title in upper case, followed by the last two digits of the year the book was published - OCR - GCSE Computer Science - Question 4 - 2018 - Paper 1

Question icon

Question 4

A-library-gives-each-book-a-code-made-from-the-first-three-letters-of-the-book-title-in-upper-case,-followed-by-the-last-two-digits-of-the-year-the-book-was-published-OCR-GCSE Computer Science-Question 4-2018-Paper 1.png

A library gives each book a code made from the first three letters of the book title in upper case, followed by the last two digits of the year the book was publishe... show full transcript

Worked Solution & Example Answer:A library gives each book a code made from the first three letters of the book title in upper case, followed by the last two digits of the year the book was published - OCR - GCSE Computer Science - Question 4 - 2018 - Paper 1

Step 1

Complete the following pseudocode for a function definition that will take in the book title and year as parameters and return the book code.

96%

114 rated

Answer

function librarycode(title, year) {
    parta = title.subString(0, 3)
    partb = year.subString(2, 2)
    return parta.upper() + partb
}
endfunction

Step 2

Use pseudocode to write an algorithm that does the following: - Inputs the title and year of a book from the user. - Uses the librarycode function above to work out the book code. - Permanently stores the new book code to the text file bookcodes.txt.

99%

104 rated

Answer

// Algorithm to store book code
Input "Enter title: " into title
Input "Enter year: " into year
newCode = librarycode(title, year)
Open bookcodes.txt for appending
Write newCode to bookcodes.txt
Close bookcodes.txt

Join the GCSE students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

Other GCSE Computer Science topics to explore

;