Loading....
|
Press & Hold to Drag Around |
|||
|
Click Here to Close |
|||
Question 1 Report
The attendance program is to be used at a college workshop. At the start of each session, a technician enters a student ID at a keyboard. The main program must reject an empty entry and IDs that are not exactly six digits before it writes a record to the attendance file. The file is later read by a separate program to display the names of absent students.
(a) Explain why validation is needed before the new attendance record is saved. [2]
(b) When the file is opened for the first time on a new day, state the most suitable file mode. [1]
In the box-office program for a small theatre, each successful booking is written to a daily file. A customer enters the number of seats required, and the program displays either a confirmation message or an error message. The manager wants the program to prevent a booking of zero seats and to keep all earlier bookings in the same file.
(a) Explain why the number of seats should be validated as greater than zero. [2]
(b) When a later booking is saved, state the file mode that should be used. [1]
Workshop attendance
Theatre bookings
Workshop attendance
Theatre bookings
Question 2 Report
In the final test of a sailing-club booking program, a family hires kayaks for 155 minutes. The club charges £9 for each complete 30-minute period and then £4 for any remaining time. The skeleton program contains the variables periods, extraMinutes and cost. The programmer must use integer arithmetic to separate complete periods from the final part of the hire. The result is displayed to the customer before payment. The following rules apply: complete periods are charged at £9, and any non-zero remainder receives one £4 charge.
(a) When periods = 155 DIV 30 is executed, state the value of periods. [1]
(b) When extraMinutes = 155 MOD 30 is executed, state the value of extraMinutes. [1]
(c) Explain why a test of extraMinutes > 0 is needed before adding £4. [2]
(d) When the family has hired the kayaks for 155 minutes, calculate the total cost. Show your working. [2]
(e) Explain one advantage of storing 30 and 9 in named variables rather than repeatedly typing these values in the program. [2]
(f) When the hire lasts exactly 150 minutes, state the total cost. [4]
(a) \(155 \operatorname{DIV} 30 = 5\), so periods is 5. [1]
(b) \(155 \operatorname{MOD} 30 = 5\), so extraMinutes is 5. [1]
(c) A positive remainder means there is hire time beyond the complete 30-minute periods, so one £4 charge is needed. If the remainder is zero, adding £4 would charge the customer incorrectly. [2]
(d) \[5 \times £9 = £45\]
There are extra minutes, so:
\[£45 + £4 = £49\]
The total cost is £49. [2]
(e) Named variables give values such as 30 and 9 meaningful names, making the code easier to read. If a tariff changes, it is edited in one place; this also reduces typing errors and inconsistent values. [2]
(f) \[150 \operatorname{DIV} 30 = 5\text{ periods}\]
\[150 \operatorname{MOD} 30 = 0\]
There is no remaining time, so no extra £4 is added.
\[5 \times £9 = £45\]
The total cost is £45. [4]
(a) \(155 \operatorname{DIV} 30 = 5\), so periods is 5. [1]
(b) \(155 \operatorname{MOD} 30 = 5\), so extraMinutes is 5. [1]
(c) A positive remainder means there is hire time beyond the complete 30-minute periods, so one £4 charge is needed. If the remainder is zero, adding £4 would charge the customer incorrectly. [2]
(d) \[5 \times £9 = £45\]
There are extra minutes, so:
\[£45 + £4 = £49\]
The total cost is £49. [2]
(e) Named variables give values such as 30 and 9 meaningful names, making the code easier to read. If a tariff changes, it is edited in one place; this also reduces typing errors and inconsistent values. [2]
(f) \[150 \operatorname{DIV} 30 = 5\text{ periods}\]
\[150 \operatorname{MOD} 30 = 0\]
There is no remaining time, so no extra £4 is added.
\[5 \times £9 = £45\]
The total cost is £45. [4]
Question 3 Report
A chemistry department stores pH results from a river survey in a file. For each sample, a student enters a location code and a pH value. The program should display a message if the pH value is not between 0 and 14, then allow the student to enter the value again. A later program reads the file to draw a graph of pH against location.
(a) Explain why the range test is appropriate for the pH input. [2]
(b) State one output device that could display the message. [1]
Table 1 shows part of a comma-separated file used by a parcel depot. The dispatch program reads each line, calculates the total mass for a delivery route and then displays the route number and total. Staff must be able to add new parcel records without deleting records already collected during the shift.
| ParcelID | Route | Mass (kg) |
|---|---|---|
| P1048 | N3 | 2.6 |
| P1049 | N3 | 1.4 |
| P1050 | W1 | 3.2 |
(a) When processing the first two records, calculate the displayed total mass for route N3. [1]
(b) State the file operation used to add a new record while retaining the existing file contents. [1]
(c) Explain why a comma is useful as a separator in this file. [2]
River pH results
Parcel-depot file
River pH results
Parcel-depot file
Question 4 Report
A scoreboard program is used during a wheelchair basketball tournament. The referee enters points through a keypad. The main program sends the new score to a large display and saves a copy to a match log file after every turn. If electricity fails, staff can read the file and restore the latest score.
(a) State the input device used by the referee. [1]
(b) Explain why writing to the log file after every turn is better than saving only at the end. [2]
Fig. 1 shows the control panel of an automated greenhouse. A grower uses the displayed controls to enter a target temperature and save it in a configuration file. On restart, the skeleton program reads the saved value and sends it to the heater controller. The grower must be warned if the entered value is outside the safe range of 10 to 35 degrees C.
(a) When the Save command is selected, explain one check the program should make on the entered temperature. [2]
(b) State one output device that could give the warning. [1]
(c) Explain why the configuration file should be closed after writing. [1]
Scoreboard
Greenhouse controller
Scoreboard
Greenhouse controller
Question 5 Report
For each photograph uploaded to a wildlife survey website, the program creates a safe file name. The function makeFileName(siteCode, photoNumber) returns text in the form siteCode_photoNumber.jpg. For example, site code RIV and photograph number 27 should produce RIV_27.jpg. A separate procedure later saves the image using this returned text. The survey team needs the same naming rule in a desktop program used at remote field stations.
(a) Explain why makeFileName should return a string rather than display the file name. [2]
(b) When called with makeFileName("RIV", 27), state the returned string. [1]
(c) Explain one advantage of using this function in both versions of the survey program. [1]
(a) makeFileName should return a string because the file name must be passed to the saving procedure or stored for later use. Displaying it would only show output and would not provide a usable value to other program statements. [2]
(b) The returned string is RIV_27.jpg. [1]
(c) Using the same function makes the file-naming rule consistent in both programs. A later change to the rule can be made once in the function rather than separately in each use. [1]
(a) makeFileName should return a string because the file name must be passed to the saving procedure or stored for later use. Displaying it would only show output and would not provide a usable value to other program statements. [2]
(b) The returned string is RIV_27.jpg. [1]
(c) Using the same function makes the file-naming rule consistent in both programs. A later change to the rule can be made once in the function rather than separately in each use. [1]
Question 6 Report
For each delivery, the bakery's ordering program calculates how many trays are needed. A tray holds 12 rolls. The program is given rollsOrdered = 86 and uses fullTrays = rollsOrdered DIV 12. The manager needs only the number of completely filled trays at this stage. A later command in the skeleton program checks for rolls that must go on a partly filled tray. The result is stored as an integer, then displayed on the packing list.
(a) When the DIV operation is completed, state the value of fullTrays. [1]
(b) Explain why ordinary division would be less suitable for this variable. [2]
Fig. 1 shows code from a bicycle-hire kiosk. A rider enters the time a bicycle was hired in minutes. The kiosk charges for every started hour, so the programmer first adds 59 before using integer division. The variable hoursCharged is then used by a subroutine that calculates the final cost. The code has been tested with a 61-minute hire. A message on the kiosk screen tells the rider how many hours have been charged.
(a) When the code shown is run with 61 minutes, state the value of hoursCharged. [1]
(b) Explain why 59 is added before the DIV 60 operation. [2]
Bakery calculation
86 DIV 12 is 7, because \(7 \times 12=84\) and only 7 trays can be completely filled. [1]DIV is more suitable. [1]Bicycle-hire calculation
hoursCharged is 2. [1]Bakery calculation
86 DIV 12 is 7, because \(7 \times 12=84\) and only 7 trays can be completely filled. [1]DIV is more suitable. [1]Bicycle-hire calculation
hoursCharged is 2. [1]Question 7 Report
Fig. 1 shows a navigation display used by a sailing club. A crew member enters a boat identifier, and the program reads a file of safety checks before displaying the boat status. The displayed message must be easy to see in rain. If no file record exists, the program sends a warning to the instructor instead of showing a safe status.
(a) State the input device used to enter the boat identifier. [1]
(b) Explain why the program should test whether a matching record was found. [2]
(c) When no record is found, state one suitable output for the instructor. [1]
Table 1 shows records from a bakery ordering file. A program reads the file at 06:00, totals the number of each product required, then sends the totals to a kitchen display. New online orders are added while the program is running.
| OrderID | Product | Quantity |
|---|---|---|
| 801 | Rye loaf | 3 |
| 802 | Seeded roll | 12 |
| 803 | Rye loaf | 5 |
(a) When these three records are processed, calculate the total number of rye loaves displayed. [1]
(b) Explain why quantity should be validated as a positive integer. [2]
(c) State the file operation needed when a new online order is received. [1]
(d) Explain why the kitchen display is an output device. [1]
Sailing-club program
Bakery-order file
Sailing-club program
Bakery-order file
Question 8 Report
Fig. 1 shows a flowchart for a parcel-locker program. The program reads a locker number, checks it, and then repeats this process while more customers are waiting. A programmer says the decision in the flowchart should be replaced by a sequence of commands because the program is already inside a loop. The service manager needs the structured program to reject locker numbers outside the range 1 to 48 and to display a useful message.
(a) Explain the purpose of the decision in Fig. 1. [2]
(b) When lockerNo is 52, state the path the program follows. [2]
(c) Explain why the error message should be displayed before the next loop iteration. [2]
(a) The decision validates the input: it tests whether lockerNo is in the permitted inclusive range 1 to 48. [1] It then selects the appropriate path: open the locker for a valid number, or display an error for an invalid one. [1]
(b) Since 52 is greater than 48, the condition is false, so the program follows the No path. [1] It displays the error message and does not open a locker. [1]
(c) The error must be displayed before the loop restarts so the customer receives feedback that their entry was invalid. [1] They can then enter a corrected locker number on the next iteration. [1]
(a) The decision validates the input: it tests whether lockerNo is in the permitted inclusive range 1 to 48. [1] It then selects the appropriate path: open the locker for a valid number, or display an error for an invalid one. [1]
(b) Since 52 is greater than 48, the condition is false, so the program follows the No path. [1] It displays the error message and does not open a locker. [1]
(c) The error must be displayed before the loop restarts so the customer receives feedback that their entry was invalid. [1] They can then enter a corrected locker number on the next iteration. [1]
Question 9 Report
Fig. 1 shows the route used by a coastal survey team to load observations from a text file into its mapping program. Each record should have three comma-separated fields: a site code, a water temperature in degrees C, and a tide state of HIGH or LOW. At a busy field station, a volunteer may leave a field blank, enter words instead of a temperature, or use an unexpected tide state. The team wants the program to keep processing later records, but it must not add an invalid record to the main data store.
(a) State the data type that should be used for the water-temperature field after it has been checked. [1]
(b) Describe three validation checks the program should apply to one imported record. [3]
(c) Explain why the invalid record should be written to an error log rather than silently discarded. [3]
(d) Write pseudocode for the main loop that reads every line in the file. Valid records must be added to observations; invalid records must cause an error message containing the site code to be added to errorLog. [5]
(a) Water temperature should be stored as a real (floating-point) number after checking, because temperatures can have decimal places. [1]
(b) Three suitable validation checks are:
HIGH or LOW. [1]A realistic temperature range check, for example \(-5\) to \(45\) degrees C, and a site-code format check are also acceptable.
(c) An error log records which records were not imported. Staff can locate and correct the original entry, rather than losing evidence, while invalid data remains out of the main data store. [3]
(d) The loop reads each line until end of file, splits it into fields, then sends valid and invalid records to different destinations.
OPEN "survey.txt" FOR READ
WHILE NOT EOF("survey.txt")
line READLINE("survey.txt")
fields SPLIT(line, ",")
IF validRecord(fields) THEN
ADD fields TO observations
ELSE
ADD "Invalid record: " + fields[0] TO errorLog
ENDIF
ENDWHILE
CLOSE "survey.txt"Opening the file and looping to EOF process every record; splitting obtains the three fields; the IF prevents invalid records entering observations while recording the site code in errorLog. [5]
(a) Water temperature should be stored as a real (floating-point) number after checking, because temperatures can have decimal places. [1]
(b) Three suitable validation checks are:
HIGH or LOW. [1]A realistic temperature range check, for example \(-5\) to \(45\) degrees C, and a site-code format check are also acceptable.
(c) An error log records which records were not imported. Staff can locate and correct the original entry, rather than losing evidence, while invalid data remains out of the main data store. [3]
(d) The loop reads each line until end of file, splits it into fields, then sends valid and invalid records to different destinations.
OPEN "survey.txt" FOR READ
WHILE NOT EOF("survey.txt")
line READLINE("survey.txt")
fields SPLIT(line, ",")
IF validRecord(fields) THEN
ADD fields TO observations
ELSE
ADD "Invalid record: " + fields[0] TO errorLog
ENDIF
ENDWHILE
CLOSE "survey.txt"Opening the file and looping to EOF process every record; splitting obtains the three fields; the IF prevents invalid records entering observations while recording the site code in errorLog. [5]
Question 10 Report
The repair workshop uses the tablet display in Fig. 1 for bicycle inspections. A mechanic enters a repair ticket, wheel diameter, number of faults and whether the bicycle is safe to collect. The ticket is used to retrieve a record, while wheel diameter helps select a replacement part. The main program calls a subroutine that rejects values with the wrong data type before the record is saved.
(a) When wheel diameter is 26.5 inches, state a suitable data type. [1]
(b) Explain why repair ticket R0031 should be stored as a string. [2]
(c) When safeToCollect is stored, state a suitable data type. [1]
(a) Wheel diameter should be a real (floating-point) number because 26.5 includes a decimal value. [1]
(b) R0031 should be a string: it contains a letter and leading zeroes, and it is a reference used to find a record rather than a value for arithmetic. Storing it numerically could lose the zeroes. [2]
(c) safeToCollect should be Boolean because the bicycle is either safe to collect or not safe to collect. [1]
(a) Wheel diameter should be a real (floating-point) number because 26.5 includes a decimal value. [1]
(b) R0031 should be a string: it contains a letter and leading zeroes, and it is a reference used to find a record rather than a value for arithmetic. Storing it numerically could lose the zeroes. [2]
(c) safeToCollect should be Boolean because the bicycle is either safe to collect or not safe to collect. [1]
Question 11 Report
Read the information below about a language-learning app. The app chooses a new word for each player by calling pickWord(level). The function selects a word from the correct list and returns it. Another procedure, showHint(word), displays the first and last letters of that returned word. The developer uses meaningful subroutine names so that another programmer can understand the main program without reading every command inside the subroutines. A fault report says that a level 3 player is sometimes given a word from level 1.
(a) Explain how meaningful names such as pickWord and showHint improve the readability of code. [2]
(b) Explain which subroutine should be investigated first for the reported fault. [1]
(a) Meaningful names state the purpose of each block: pickWord selects a word, while showHint displays a hint. A programmer can therefore follow the main program without inspecting every command inside each subroutine, making maintenance easier. [2]
(b) Investigate pickWord(level) first, because it selects the word list and returns the chosen word. It is the subroutine responsible for choosing a level-appropriate word. [1]
(a) Meaningful names state the purpose of each block: pickWord selects a word, while showHint displays a hint. A programmer can therefore follow the main program without inspecting every command inside each subroutine, making maintenance easier. [2]
(b) Investigate pickWord(level) first, because it selects the word list and returns the chosen word. It is the subroutine responsible for choosing a level-appropriate word. [1]
Would you like to proceed with this action?