ExamBank Scot · N5 Computing Science question bank · All N5 Computing Science questions
16 marks · Running total within a loop
Using a design technique of your choice, refine step 2. A member’s average additional calories burned is displayed using the line of code below. SEND avgCalories TO DISPLAY This code displays the value below to a member. 5123.879 Using a programming language of your choice, rewrite this code to display the average additional calories to one decimal place. If a member’s average additional calories burned is over 6000 calories, and they have a personal trainer at the gym, they will be given a 15% discount on their next session. The code to implement this is shown below. … Line 27 SET memberDiscount TO 0.00 Line 28 <repeat for every gym member> Line 29 Line 30 IF avgCalories < 6000 AND trainer = TRUE SEND "Congratulations on a 15% discount" TO DISPLAY SET memberDiscount TO sessionCost * 0.15 Line 31 Line 32 END IF Line 33 <end repeat> … Identify the logical operator in the above code. It was identified that a member who burned 6578.1 average additional calories and who has a personal trainer did not receive the 15% discount. State the type of error in the program and how the error can be corrected. Type of error Correction After final testing, the program is run without requiring any further translation. State the type of translator that has been used. State the term used at the evaluation stage, to describe a program’s capability to handle unexpected or incorrect data being entered without crashing. A member has written an e‑mail to the gym manager. State what can be done to ensure that, if intercepted, the e‑mail cannot be read by others. The gym manager wants to set up tablet computers at the door to carry out a survey as people leave the gym. The survey should ask if they are a member or a pay‑as‑you‑go customer, and if they were attending the gym or a fitness class. The survey should also ask people to rate their visit, from 1 to 10, and have a space for any additional comments. Design a user interface for this survey. A gym wants to encourage members to burn more calories than their monthly target. It uses a program to calculate additional calories burned over a 12‑month period. … April May June … ... 6821.34 5129.89 4997.67 ... The design below shows how a member’s average additional calories burned is calculated and displayed. 1. Store each month’s additional calories burned 2. Calculate the average additional calories burned 3. Display the average additional calories burned The data structure calories is used to store additional calories burned each month. The variable avgCalories is used to store the user’s average additional calories burned.
• loop for each month (12 times) • running total adding calories to total in loop • use next value in calories • calculate avgcalories from total variable Must use structure and variable names given. Average could be calculated by dividing each value inside loop by 12 before adding to running total. • round() function with brackets • with correct parameters: - avgCalories - 1 AND • logic • < should be > Line 29 <6000 should be changed to >6000 Compiler Robust(ness) Encryption Entry of • member or pay as go • gym or fitness class • rating 1 - 10 • additional comments Input area and user instruction for text entry may be combined within one box for a single input. Ignore any additional objects/text/ buttons that may have been added to the user interface. Award 0 marks if the candidate has designed a program (pseudocode, flow chart, structure diagram) rather than a user interface.