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.

99%

104 rated

Answer

start
    // Input title and year from user
    output "Enter title:"
    input title
    output "Enter year:"
    input year

    // Use the librarycode function to get the book code
    code = librarycode(title, year)

    // Permanently store the new book code to the file 'bookcodes.txt'
    open file "bookcodes.txt" for appending
    write code to file
    close file
end

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

;