ExamBank Scot · N5 Computing Science question bank · All N5 Computing Science questions
7 marks · Assignment, arithmetic and concatenation
Step 6 in the algorithm calculates and updates the total cost. Using a programming language of your choice, write the code for step 6. The total cost should be output as shown below. The cost is £14999.50 for the windows Using a programming language of your choice and the variable name totalCost, write the code to produce the output above. A hotel wants to replace 114 windows. Convert this denary number to 8-bit binary. A window replacement company employs a programmer to write a program that calculates how much it will cost to fit triple glazed windows. Small windows cost £299.99 and large windows cost £499.99 to replace. The algorithm to calculate the cost is shown below. 1. Set totalCost to 0 2. Ask for number of rooms 3. Loop through the number of rooms 4. Ask for the number of small windows 5. Ask for the number of large windows 6. Calculate and update totalCost 7. End loop 8. Display totalCost
One mark for the following code: • calculation of small windows cost • calculation of large windows cost • running total updated • assignment to totalCost Sample one line answer: SET totalCost TO totalCost + (numSmall * 299.99) + (numLarge * 499.99) Sample three line answer: SET small TO numSmall * 299.99 SET large TO numLarge * 499.99 SET totalCost TO totalCost + small + large One mark for the following code: • display the correct text using quotes • totalCost variable used between text with appropriate separators Example answers can include: SEND "The cost is £" & totalCost & " for the windows" TO DISPLAY 01110010