ExamBank Scot · N5 Computing Science question bank · All N5 Computing Science questions
11 marks · Floating-point representation
The data usage for the customer in May is 35.7 GB. This value would be stored in a computer system using floating-point representation as shown below. 0.357 × 10² Identify the mantissa and exponent in the above floating-point representation. Mantissa Exponent The design below shows how a customer’s average monthly data usage is calculated and displayed. Algorithm 1. Store each month’s data usage 2. Calculate the average monthly data usage 3. Display the average monthly data usage The data structure month is used to store the data usage. The variable aveData is used to store a customer’s average monthly data usage. Using a design technique of your choice, refine step 2. A customer’s average monthly data usage is displayed using the following code. SEND aveData TO DISPLAY The above code displays the following value to a customer. 23.3123 Using a programming language of your choice, re-write this code so the customer’s average monthly data usage will display as the following. 23.3 The following code checks if the customer receives both their mobile data and broadband from the company before offering them a discount. … Line 44 SET custDiscount TO 0.0 Line 45 < Repeat for each customer > Line 46 IF mobileData = TRUE AND broadband = TRUE THEN Line 47 SEND "You are due a 20% discount." TO DISPLAY Line 48 SET cust Discount TO bill * 0.2 Line 49 END IF Line 50 < End repeat> … Identify the logical operator in the above code. During translation the program stops and produces an error at line 48. State the type of error that the programmer has made and how the error can be corrected. Type of error Correction A communications company uses a program to calculate a customer’s average data usage over a 12-month period. An example of a customer’s monthly data usage in gigabytes (GB) is shown below. … Feb March April May June July Aug … 50 41 30.8 35.7 32.7 23 19
One mark each for the order shown: • 357 • 2 One mark for each of the following designed: • loop 12 times • updating running total within loop • using stored array values • calculate average total/12 Example answer: 2.1 Loop 12 times 2.2 Set total to total month [index] 2.3 End loop 2.4 Set aveData to total/12 Award mark if average divides by the same number of loop iterations. One mark each for: • round() function • correct parameters aveData,1 Display/print/assignment not required in answer as given in question. Example answer: round(aveData,1) AND One mark each for: • type - Syntax • fix ‘cust’ and ‘Discount’ variable corrected (to custDiscount