Advertisement
timber101

Pupil Code - Exam Question

Jan 19th, 2022
33
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None
  1. Pupils in school are allocated a pupil code identifying them as follows last two digits of the year started then First 5 Digits of surname and First initial. We are assuming all pupils have a surname of at least 5 characters
  2. For example, Freda Bloggs who joined in 2021 would have the code 21bloggf
  3. (a) Complete the following pseudocode for a function definition that would take year, surname and first name as parameters and return the pupil code
  4.  
  5. 01 function pupilcode(year,…………………… ,……………………)
  6.  
  7. 02 yrpart = year.subString(2,2)
  8.  
  9. 03 snpart = surname.subString(0,……………………)
  10.  
  11. 04 fnpart = firstname.subString(0,1)
  12.  
  13. 05 ………………… yrpart + snpart.lower + fnpart.lower
  14.  
  15. (b) Use pseudocode to write the algorithm that does the following
  16. • Inputs the year, surname and first name of the pupil
  17. • Uses the pupilcode function to work out the pupilcode
  18. • Adds the pupil code to a text file as a permanent record called pupilcodes.txt
  19.  
Advertisement
RAW Paste Data Copied
Advertisement