64% found this document useful (22 votes)
17K views48 pages

IGCSE Computer Textbook Answers (Hodder Education)

Answers to Computer Science textbook

Uploaded by

Zara Danish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
64% found this document useful (22 votes)
17K views48 pages

IGCSE Computer Textbook Answers (Hodder Education)

Answers to Computer Science textbook

Uploaded by

Zara Danish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 48
Introduction é This teacher's resource provides a range of teaching and reference materials which have been developed to aid the teaching of the Cambridge International Examinations IGCSE* Computer Science syllabus (0478), These resources support the Cambridge IGCSE Computer Science textbook (by Watson and Williams), which has been endorsed by Cambridge International Examinations. Scheme of work The scheme of work has been devised to foliow a logical route through the new IGCSE® Computer Science textbook. Its aim is to complete the course by the end. of the second term in the second year of study; this will then allow adequate time for revision and exam practice. It is assumed that students will have 344 hours per week study time in this topic (total study time over 5 terms: 245 hours, comprising 145 hours for section 1 and 100 hous for section 2). To ensure a good balance, it is also assumed chat sections 1 and 2 of the Cambridge syllabus will be taught side by side; the scheme of work will therefore assume 2 hours per week on section 1 of the syllabus (theory) and 14 hours perweek on section 2 of the syllabus (practical). Naturally this can be modified depending on resource allocation and other factors. The relevant chapter and pages in the textbook and the syllabus references are Getailed, as well as activities from the textbook; additional lesson notes are also included. Answers Answers to the end-of-chapter questions and (where relevant) the activities in the textbook are provided. Examination-style questions The Paper 1 examination-style questions with answers will be especially usefil for teachers. They are based on the chapters in section 1 of the textbock. Teachers can select questions or question parts to make their own tests, or use the questions as provided. In general the level of difficulty of a question increases as the students work their way throngh the question. For example, all students should be able to tackle part a (shown with a green dot @); most students should be able to tackle part b (shown with an orange dot @); and those students aiming for the top grades should be able to tackle part ¢ (shown with « parple dot @). Answers for all questions have been provided, using this same colour coding. Sometimes there is additional commentary on the answers. Program files ‘The Python and Java program files are for use with the activities and end-of-chapter questions. Additional content in the textbook Whilst asymmetric encryption is not in the present syllabus it was included in the textbook for two reasons: 4 to give a more complete picture on how encryption works (since student discussions may involve ways of improving the security of data by this method) 2. itis helpful to include asymmetric enceyption when studying security systems on the internet such as SSL and TLS. Cambridge IGCSE Computer Science Teacher's CD © David Watson & Helen Williams 2015 @ ees Science Introduction Scheme of work Section 1: Theory of computer science Chapter 1 Binary systems and hexadecimal Chapter 2 Communication and internet technologies Chapter 3 Logic gates and logic circuits Chapter 4 Operating systems and computer architecture Chapter 5 _ Input and output devices Chapter 6 Memory and data storage Chapter 7 High and low level languages Chapter 8 — Security and ethics The questions, sample answers, ais owed and/or comments tot appear in tis CD were writen bythe cuthor, Progr las fr Chaptars 11-13 ean abe be found in CAMIGCSECOMPTE Resources. Cambridge Com puter b brat LEARN MORE TEACHER'S RESOURCE Section 2: Practical problem-solving and programming Chapter 9 Problem solving and design Chapter 10 Pseudocode and flowcharts Chapter 11 Programming concepts Chapter 12 Data structures: arrays Chapter 13 Databases Paper 1 examination-style questions and commentaries Paper 2 pre-release material Help Licence Answers to Chapter 1 questions Activity 1.1 St 127 153 116 255 1S 143 240 112 239 Activity 1.2 00101001 01000011 01010110 a b © d 01100100 e 01101111 f g h i I ssa sea0ce o1ndi11 10010000 10111101 11001000 q4naat4 Activity 1.3 ‘a i motorB ON, motor C OFF, B direction is forwards; ‘overal effect: robot pivoting to the left about wheel C ii. motor B ON, moter C ON, B direction backwards, C direction backwards overall effect: robot moving backwards in a straight line ili motor B ON, motor C ON, B direction backwards, C direction forwards overall effect: robot is turning to the right b 01100001 © 10100110 d error Activity 1.4 c3 F7 278 4EE 161 BSE are (EOC FF7D (E7AE -oreseance Cambridge IGCSE Compuiter Scierice Teacher's CD © David Watson & Helen Williams 2015 8 ANSWERS TO CHAPTER I QUESTIONS Activity 1.5 sare acce 01101100 01011001 10101010 101000000000 010000001110 101110100110 100111001100 0100000010101010 1101101001000111 0001101010110000 Activity 1.6 oso se aonce 107 156 74 255 $11 2561 2996 3240 4782 44425 Activity 1.7 yatnance j 62 £3 18a FF 33A BEB Aaa ESF FAT 1388 Activity 1.9 b wwwcie org.uk Y%77%77%77 WZE %E3% ES WES % 2E% GF %72 ME? MS 2E 75 HEB ‘www.cie.org.uk/computer_science %77%77% 77 %2E%E3%E9 65% ZE Yo EF 972 HE? MLE 7S HOB Ve 2F%E3 WEF MED %70%75%74%65%72% SF %73%63 %E9 % WES MEE EINES httpsy/wawhodder.co.uk %58%74% 74.%70% 73% 3A% 2F % 2F %77 %77 77 HE KES VF %O4 %E4%ES 72 Yo2E YE 3% EF% 2E%75%EB ‘www HodderEducation.co.uk %77%77 %77 YE %A4B WEF %E4%E4%ES %7 2% 45 %E4% 7S 9063 1061 749069 WEF VEE %2E% 63 MEF %IE%7S%EB httpAwww.udes.ac.uk/computing.htm Yo68%74% 74% 70% 3A %2F Ye 2F% 77 477 %77 W2E%7 SHES WBC OS 07 3% ZEWE %E3%ZE% 75 %6B% 2F% 63 VEF %ED% 70% 7 5% 74 %69% GE %E7 %IE%EB%74 HED Cambridge IGCSE Computer Science Teacher's CD © David Watson & Helen Williams 2015 e Answers to Chapter 2 questions Activity 2.1 ‘a data sent one bit at a time over a single wire/channe’ in both directions but not at the same tme b several bits of data sent Gown several wires/channels in both directions at the same time ¢ data sent one bit at a time over a single wire/channel in one direction only Activity 2.2 parity bit = 1 parity bit = 1 parity bit = 0 Activity 2.3 OK error following transmission error following transmission OK error following transmission Activity 2.4 Byte 4 row and bit 6 column show error (incorrect parity) Bit value ‘0’ at intersection of row 4 and column 6 is in error Byte should be: 01101110 Activity 2.5 a 148 b 137 ¢ 170 d 255 cance eance Cambridge IGCSE Computer Science Teacher’ CD @ David Watson & Helen Williams 2015 @ 2S Answers to Chapter 3 questions Activity 3.1 Input values alse | Valuo: Value [value | Outputs A B {a.b) (a-b) a+b) a. 4; 3 pres foes Tisropon a aie i 5 0 ¥ oO 1 i 1 1. cero ee estat 4. 1 0 o C 1 oO 0 Both truth tables have the same output (columns 5 and 8). Hence both expressions are the same. Activity 3.2 a puts ‘Queput x 3 5 5 i 4 fi 5 ; t ; ° EES Slelcte: Slefele Inputs Output A 8 c x o 0 3 7 @ ° 1 1 0 i 6 0 2 1 1 1 i fo. 0 2 i 0 1 1 1 1 7 o 1 1 ih 1 Cambridge IGCSE Computer Science Teacher's CD © David Watson & Helen Williams 2015 ANSWERS TO CHAPTER 3 QUESTIONS a inputa y Output A 5 © x ° ° 3 Set n i i 0 | 3 1 e 1 0 i i fl o 2 ° 0 oe o 1 1 7 1 o 1 o 1 i a e Inputs Output A 5 x ° o ° 3 é 0 i 3 ° i ° o 3 1 ti 7 i 0 o 1 7 0 1 7 i 1 0 0 1 i 1 1 Activity 3.3 a X=1if(A=10RB= 1) OR (A= 0 ANDB=1) Te —D- 1 WT) Inputs Output 4 B x ° 0 é 0 1 1 i ° 1 1 1 1 b Y=1if(A=0 AND 8B =0) AND (8 =0ORC=1) s— pe pb s>=—_p>— ¥ ¢<———_——D— Cambridge IGCSE Computer Science Teachers CD © David Watson & Helen Williams 2015 ANSWERS TO CHAPTER 3 QUESTIONS inpute Oita A | B c ¥ 0 0 3 1 0 0 4 rh o 1 2 3 0 1 i 2 1 0 0 ° z 2 4 o 1 1 o 0 1 1 i o o if = 1 ORL= 1) OR(K = 1 AND M=NOT 1) OR(M = 1) ae i a te 3 3 1 : a i 1 i o 1 1 1 oO 1 4 1 DH => ‘ DH inputs Output A B c x 9 oO i oO 5 : 2 9 t 2 3 ; 1 3 1 i 1 t 0 9 4 1 1 oO Gembridge IGCSE Computer Science Teacher’s CD © David Watson & Helen Williams 2015 e ANSWERS TO CHAPTER 3 QUESTIONS (A = 1 AND 8 = 1) AND (8 = 1 OR C = NOT 1) a4 Lr Inputs Output =|=Tele|=|-lele Activity 3.4 a X=1 if (R= NOT 1) OR (C = 1 AND T=NOT 1) OR (R= 1 AND T =NOT 1) Get —> inputs Ourput i 0 ° 0 0 1 1 0 0 i 1 b S=1 if (G= 1 AND W=NOT 1) OR (G = NOT 1 AND R=1)OR(W=1 AND R= 1) 6 Hy Cambridge IGCSE Computer Science Teacher's CD © David Watson & Helen Williams 2015 eo ANSWERS TO CHAPTER 3 QUESTIONS Activity 3.5 Fintt logic circuit: syel=Je =Telele which confirms this as an AND gate. Second logic circuit: which confirms this as an OR gate. Third logic circuit: Input | Output] A x 0 1 0 which confirms this as a NOT gate. Activity 3.6 DS ae Cambridge IGCSE Computer Science Teacher’ CD © David Watson & Helen Williams 2015 ANSWERS TO CHAPTER 3 QUESTIONS inp Guepietom «| OueputhromNAND | X . < original cite (gate only revit 0 0 2 1 Hi 0 0 1 0 0 ° 7 0 1 1 ° 1 + a ° fi o 2 i 1 1 0 1 2 ° t 1 0 1 n Ee 1 1 f which confirms that the two logic circuits have the same function. b_ NAND-gate only circuit: a sD DDD aoe Dd DH ‘¢ This gives the following truth table: a=yST> 0 1 0 1 el=|=lo which confirms that the logic circuit represents the XOR gate. Activity 3.7, Inputs Output a 8 x 0 a i oe 1 o 1 o 0 i 1 0 which is the truth table for the NOR gate. Activity 3.8 Inputs Output A 5 x o 0 i 0 i [o 1 0 @ 1 1 @ which is the truth table for the NOR gate. Cambridge IGCSE Computer Science Teachers CD ® David Watson & Helen Williams 2015 e ANSWERS TO CHAPTER 3 QUESTIONS which indicates that the logic circuit could be replaced by Input R only. Cambridge IGCSE Computer Science Teacher's CD © David Watson & Helen Williams 2015 e Answers to Chapter 4 questions ‘There are no suggested solutions to the activities in this chapter. Cambridge IGCSE Computer Science Teacher's CD © David Watson & Helen Williams 2015 o | » Answers to Chapter 5 questions Activity 5.1 a 9003-40 would have the following barcode sequence: left-hand sid LLLDLDDALLLODLO/LLLDDLO right-hand side: LLLLDUDLODDLUDODLLDL 12576648 leftchand side: LLDDLLD/LLDLLDDALDDLLLDLDDDLOD right-hand side: DLDULLUDLDLLLLIDLODDLUDLLDLLL 0588902918 lefichand side: LLLDDLD/LDDLLLDADDLDDDADDLDDDLLLOLOD right-hand side: DODLLDL/ODLDDLUDDDLOLUDDLLDDL/DLLDLLL Cambridge IGCSE Computer Science Teacher's CD ® David Watson & Helen Williams 2015 @ ANSWERS TO CHAPTER 5 QUESTIONS Activity 5.6 Possible flowchart (other solutions cxist which are probably just as correct!!): Send sensor eacing ‘tb microprocessor Micropracessor ‘compares the reading ‘with stored values Yes No Settimer to 30 minutes Set timer to 30 minutes Switch lamp OFF ‘switch lamp ON ‘Count down in minutes Court down in minutes Yes | Ne No Yes | Activity 5.10 @ 176 400 bytes needed per second of recording Soa 4-minute recording needs: 240 x 176 400 bytes, .e. 42 336 000 bytes Dividing by 1 048 570 gives answer in MB, i.e. 40.37 MB b 80040,37 = 19.82 So 19 full tracks could be stored on this CD. Cambridge IGCSE Computer Science Teacher's CD © David Watson & Helen Williams 2015 6 Answers to Chapter 6 questions Activity 6.1 a number of minutes =3+5+64+4+5+4+24+7+8+8=48 48 minutes requires 48 x 12 M8 = 576 MB b 90% reduction leaves file size of 10% x 576 MB = 57.6 MB © average track length = 48/9 = 5.33 minutes so each track needs 5.33 x 12 MB = 63.96 MB in MP3 format, each track uses 6.396 MB of storage 50 800/6.396 = 125 tracks can be stored Activity 6.2 a i 1200x1600 = 1 920 000 pixels ii 3 bytes per pixel = 5 760 000 bytes lit reduced by a factor of 8 cives 720 000 bytes = 703 KB b i 3072x2304 = 7 077 888 pixels 3 bytes per pixel = 21 233 664 bytes = 20.25 MB reduced by a factor of 5 gives 4 246 733 bytes = 4.05 MB iv 4 GB/20.25 MB = 4096 MB/20.25 MB = 202.27 So 202 uncompressed files can be stored. V4 GB/d.05 MB = 4096 MB/4.05 MB = 1011.35 So 1011 compressad files can be stored Cambridge IGCSE Computer Science Teacher's CD © David Watson & Helen Williams 2015 e@ Answers to Chapter 7 questions “The answers for the activities are suggestions; there are many other possible answers Activity 7.1 1 Payroll 2. Registration 3. Attendance records 4 Recording marks 5. Student records 6 Rum an internal network for students 7 Run an internal network for acmnistration 8 Timetabling 9 Exam registration 40 Room bookings Activity 7.2 CH general purpose, lots of different applications for example electronic ticketing Delphi writing standalone applications with GUIs Java object-oriented programs that run on any platform Pascal teaching programming Python control and testing Visual Basic RAD for event driven applications 1 PHP ‘open source scripting language used for web develoament 2 Modula3 industrial and research projects and teaching 3 Perl databases end email handing 4 Swift building Apple applications 5 MATLAB vector operations Activity 7.3 1 MASM x86 - games, high speed datz manipulation 2 TASM 6502 — used to write routines for use with high-level languages developed by Borland Activity 7.4 1 80807280 load - OA, add - 87, store- 47 2 ¥86-64 load -A4, add - 04, store - AA. Activity 7.5 P’m using Microsoft Visual Studio with VB.net; this is an IDE because it offers me an edicor and a debugger as well as other built-in tools including a forms designer. End-of-chapter questions 1. Totrenslate 2 progrem written in a high-level language, you can use a compiler or an interpreter To translate a program written in a low-level language you must use an assembler. 2 a Programa b_ Because the statements are made up of commands that use simple English words to describe what is to be done. © Program A (Cambridge IGCSE Computer Science Teacher's CD © David Watson & Helen Williams 2015 @ ANSWERS TO CHAPTER 7 QUESTIONS 3 Aprogrammer can understand @ program written in a high-level language more easily than 2 program written in a low-level language. This makes high-level language progrems easier to debug and maintain. The development time for a program writien in a high-level language is usually shorter than that of 2 similar program written in a low-level language. 4 A program written in a low-level language takes up less space in memory than a similar, program written in a high-level language. Also 2 program written in a lowslevel language Usually has a faster execution time than a similar program written in a high-level langvace. Programs written in a low-level language can make direct use of specific hardware whereas programs written in @ high-level language can only use routines already provided with the hardware. 5 Aprogram written in @ high-level language cannot be executed by a computer. A compiler translates a whole program into machine code provided there are no syntex errors. An interpreter executes each program statement, written in a high-level language, until a syntax error is found. A compiler provides a translated machine code program that can be run independently; an interpreter does not ~ the high-level language statements are executed in order, no machine code program is produced. 6 To develop @ program | would use an interpreter for the following reasons: ‘@ Debugging is easier since the interpreter stops the execution of the program when an error is found. © No need to wait for the program to recompile after an error has been corrected @ Program execution can start from the correction point. Cambridge IGCSE Computer Science Teachers CD © David Watson & Helen Williams 2015 @ Answers to Chapter 8 questions Activity 8.1 a Stage Sender Recipient the sender Uses an encryption elgertim (ee | the recipient uses the same algorithrn and 1 later) and chooses 2 value — 2lso chooses avalue - e.g. X= 3 isis keot secret) eg. Y= ithis is ago kept secret) this value of X's put into a simple algorthm: | the value of Ys put into the same algorithm: 7 Moo 11) 7 (oD 11) (MOO gives the remainder when dviding 3 | (MOD aives the remainder wren cing a ‘eumber by 11) umber by 11) 2 | this aves: this cives: (MOO 11) = 343 (VOD 11) P (MoD 11) = 16807 (MOD 11) ihc gives the value: which gives the value: 2 (he. 31 remainder 2) 410 G2. 1527 remaieder 10) 3 | te sender now sencs the value just the recipient now sends the vale ust calculate fie. 2) to the reciient Icelulated fie. 10) to the sender ris new value fs put into the seme this new value is put into the same alaoritvi algoritam =the new value replaces “7°: | the neve value replaces "7": | 10 (MoD 11) 2* (Mob 11) | 4 [Ris gives: this gives | 19? (op 11) = 1000 (MoD 11) 2 (MOD 11)= 32 (VOD 11) | jwhich gives the value: which ves the valve: | 40 (.¢ 90 reminder 10) 10(.2. 2 remainder 10) b ss Stage ‘Sender Recipient The sender uses an encryption algorithm (see | tre recipiant wes the some slgorthm and 1 flaten ans chooses a vaie = aso chooses a value ~ e.g. X=7 Ith is kept secret) e.g. ¥ = 6 (this s also kept secred itis value of Xb put into e smnple algorithm | the value of ¥is put into the same algorithm: 7 (MOD 11) T (MoD 11) (MOD gives the remsinser when cimcing a | (VOD gives the remaincer when chiding a number by 11) number by 11) 2 this gives: this cives (MOD 11) = 823543 (MOD 11) 7#(MOD 11)= 117649 (MOD 11) hich gies the value ‘nich ges the value | 6 (.2. 74867 remainder 6) 4.2. 10695 remainder 4) 3 [thesencer now sends the value ust, the recpent now sends the valve just calculated (i.e. 6) to the recipient calculated (.c. 4 to the sender This new velue is put into the same ‘this new valve is cut into the same algorthm algorithm =the new value replaces “7~: | the new value replaces “7°: 200 11) 67 (MOD 11) 4 [this cies this gives: 4" (MoD 11) = 16384 (MOD 11) 6! (MOD 11) = 46655 (MOD 11) hich aves the value: which gives the value: 5 (he, 1489 remainder 5) 5 (ie. 4241 remainder 5) Cambridge IGCSE Computer Science Teachers CD © David Watson & Helen Williams 2015 Answers to Chapter 9 questions Activity 9.1 © Weather forecasting — large Social networking — large © Engine management for car ~ small ® My calendar ~ small © Supermarket ~ medium/large Activity 9.2 Check time jeg ese] [Check slam time Check sud somes | | ESM | mick ne Activity 9.3 There are many answers, as this is a complicated open-ended problem, for example: Clean tet sees totrirash] [Load wootnrsh a and toothpaste ‘and brush teeth . Activity 9.4 Purpose: select the highest number Output: 18 is largest Activity 9.5 Data: 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 Expected result: 58 Activity 9.6 Data: 370, #, -99 Expected results: these values should be rejected. Activity 9.7 Boundary data for 100 is 100, 101 Expected results: 101 is rejected, 100 is accepted. Cambridge IGCSE Computer Science Teacher's CD © David Watson & Helen Williams 2015 @ ANSWERS TO CHAPTER 9 QUESTIONS Activity 9.8 a. Normal data: 5,554 5,9) 51518 5.3 Expected result 5 1,2,3,4,5,6,7,8,9, 10 Expected result 5.5, b Erroneous data: 30, #, -99 Expected results: these values should be rejected. © Boundary data for 20s 20, 21 Expected results: 21 is rejected, 20 is accepted Boundary data for 0 is -1, 0 Expected results: ~1 is rejected, 0 is accepted. Activity 9.9 1 4849464 2-0+37+1+04144+ON10 = 7 remainder 3 Check digit = 10-3 =7 2 GH14740+7+540+37+848+141+ 0/10 = 10 remainder 4, not correct 4842442648474 A741 4345474910 = 14, correct Activity 9.10 Scudents’ answers will vary. The system will not identify transposition of two odd or two even numbers. Activity 9.11 Look at hep: //auto howstuffworks.com/buying-selling/vin.htm Activity 9.12 Limit check ~ checks against an upper or lower limit only. Consistency check ~ checks that data in two or more fields correspond, for example if the data in the ficld Title is Mr the data in the ficld Gender should be male. Activity 9.13 ‘a Phone number — type check and length check b Student's name ~ character check Part number ~ format check Activity 9.14 A 8 C x Output 3 @ 100 7 4 2 3 3 19 ie 19 4 AT 17 5 5 3 6 ii 7 SAE B 1 3 4 3 3 10 [s feo Cambridge IGCSE Computer Science Teacher's CD © David Watson & Helen Williams 2015 ANSWERS TO CHAPTER 9 QUESTIONS Activity 9.15 a B c x Output 0 9 100 4 400 400 2 00 00 Se [790 2 170 i 5 Ree 300 6 10 7 [600 8 150 9 430 10 300 300 900 100 0, -20, -40, ~50, -60 0, : A 8 E x ‘Output 100 0 1 [ =10 =10 2 =20 a0 3 30. 30 4 = 5 =16 6 =10 2 220 8 40° AC g “30 “50 70 =60 60 joss There is an error as the largest number has not been identified. Activity 9.17 Reo : INPUT x ; Bex cox REPEAT = INpur x 1 x>B THEN Bo x ELSE wxec THEN C « x ENDIE ENDIE bo aeass UNTIL A= 5 j SEE AB ES 2 a it tence renee | Cambridge IGCSE Computer Science Teacher’ CD @ David Watson & Helen Williams 2015 86 ANSWERS TO CHAPTER 9 QUESTIONS Activity 9.18 The weight of the child is not required; the tests are repeated. A more efficient solution would be TF Age >= 5 OR Height >= 1 i hg oii TREN OUTPUT "OK" ELSE OUTPUT "You cannot ride" _ENDIE End-of-chapter questions | 1. Software Data Hardware Communications People 2 Modilo 1 Breck digit ; Cease Cutout number Check ength check digit wah check gt 1 i Find length ot | | Rejectoutof 3. a Number of diners range check 2 to 12 inclusive, bill range check 10 to 500 inclusive 1b Normal set 1: 4, $40 - expected result $10 j Normal set 2: 6, $33 - expected result $5.50 j Abnormal data: 2.5, $5 j fred, -617 ’ 4 Boundary data: 12, $500 expected result $41.67 4 Validation is checking that data is reasonable; verificat on is checking that data has been copied accurately. 5 Name - validation using a presence check, 25 a name would be required | Date of birth — validation using a range check to check neither too old nor too young Password ~ verification by double entry, validation using length, and character checks Phone number ~ validation using length check and character check (digits and certain characters, for example + only) 6 a 94+843+0+8+8+37+0+4+94342)10 = 11 remainder 1 Check digit= 10-1=9 b 948454+1474643+H7 +0+24+140+5)0 = 8 remainder 4, therefore incorrect (4+84+5+645+04+5+37+0+941+8+ 810 = 13 remainder 8, therefore incorrect Cambridge IGCSE Computer Science Teacher’ CD © David Watson & Helen Williams 2015 . ANSWERS TO CHAPTER 9 QUESTIONS Ta Counter | Length | Breadth | vArea | Accept | Reject Output 0 il o 0 7 15 10, 150). auey 2 20, 1? +340, 2 3 32, 10, fa 1 4 Ey 35 2 S 30 15 450, 2. 1 6 30 28 840 3 [ 7 25 25 625, 4 a 20 15 300 [4 9 40, 20 5 19° 12 10 120) L 5,5 b_ Both length and breadth must be less than or equal to 30 cm; area must be less than or equal to 600 cm? ¢ The algorithm is not efficient as neither the weight nor the volume of the parcel are considered. Ba counter <1 is not required for a FOR ... NEXT loop Total « 0 Total should be set to zero Counter + Counter +1 is not required fora FOR ... NEXT loop REPEAT PRINT "Enter a positive whole number" INPUT Number UNTIL Number < 0 will reject all positive numbers Total < Total + Counter will not total the numbers input OUTPUT Total the total will be output many times b TheuseofaFOR ... NEXT loop is effective but the Total. should only be output ‘once after the end of the loop. c Total <0 FOR Counter + 1 70 10 REPEAT PRINT "Enter a positive whole number" INPUT Number UNTIL Number > 0 Total « Total + Number NEXT OUTPUT Total Cambridge IGCSE Computer Science Teacher's CD ® David Watson & Helen Williams 2015 6 ANSWERS TO CHAPTER 9 QUESTIONS 41,4, 3, 7, 7, 10, 12 10. fiz 6 [es © Normal data 6,7, 11,4, 3,7, 7, 10, 12 Erroneous data 0,1 Extreme data 1 (1 is normal as well because itis accepted) 9 Length check, for exemple to check if an id number is exactly 8 characters long, Range check, for example to check if @ person's age is in the range 11 t0 19 10 Several programmers can work on the development of the same software package {tis easier to debug individual modules than a whole program. {tis easier to test individual modules than the whele program. 11. Format check, length check 'b Range check ~ user ID is a mixture of letters and numbers Cambridge IGCSE Computer Science Teacher's CD © David Watson & Helen Williarns 2015 .) Answers to Chapter 10 questions Activity 10.1 Amount, 100 TotalPrice 350 Discount 0.2 ‘Binalprice 280 cae valet [Message "Helio wis Activity 10.2 INPUT BezcentageMark IP Percentagelfark < 0 OR PercentageMark > 20 THEN PRINT "Invalid Mark" i ELSE IP Percentagetiark > 9 THEN PRINT "Paso" ELSE PRINT "Fail" ENDIF ENDIF Normal data - 4 Boundary data 0, 20 accepted -1, 21 rejected Erroneous data -11, a Activity 10.3 CASE Day OF 1: PRINT "Sunday" PRINT "Monday" : PRINT "Tueeday" PRINT "Kednesday" PRINT *Thursday" + PRINT "Friday" 7: PRINT "Saturday" OTHERWISE PRINT "Error" muncnse Activity 10.4 a. z Toei row Counser « XlNe 10 INPUT Number Total « Total + Suber next [average + Total/10 Cambridge IGCSE Computer Science Teacher’s CD © David Watson & Helen Williams 2015 @ ANSWERS TO CHAPTER 10 QUESTIONS b Using -1 to finish otal <6 Counter © 1 INPUT Number REPEAT Total « Total + Munber Counter = Counter + 1 INPUT Mumber UNTIL Munber = -1 Average x Total/Couny © Why the loop structures were chosen: FOR ... NEXT loop as the number of repeats is knowa, 10. REPEAT ... UNTTT, loop as oumber of repeats is not known and an ending condition can be tested. Activity 10.5 0, 26 Erroneous 1,25 Boundary 9,10 Boundary 19, 20 Boundary More data: 2, 17, 22 Expected results 40, 306, 352 Cambridge IGCSE Computer Science Teachers CD © David Watson & Helen Williams 2015 ANSWERS TO CHAPTER 10 QUESTIONS Activity 10.6 a Changes are shown in red. foveratitighest’ <0 es foveralltiowest: « 100 ovaralifotal + 0 HyOR Test « 1 to 2 SubjectHighest + 0 | SubjectLovast + 100 SubjectTotal « 0 CASE Test OF 1: SubjectName « "Matns' 2 + SubjectNane « "Scienc S—Subjecttiane -2 IF Mark < Overalllowest THEN OverallLowest « Mark TP Mark < Subjeczlowest THEN SubjectLowest < Mark TP Mark > QverallHighest THEN OverallHighest ~ Mark TP Mark > SubjectHighest THEN Subjectiiighest « Mark Overalltotal « OverallTotal + Nark SubjectTotal < SubjectTotal + Mark NEXT SubjectAverage + SubjectTotal/s PRINT subjectName PRINT "Average is *, SubjectAverage PRINT "Highest Mark is ", SubjectHighest | PRINT "Lowest Mark is ", SubjectLowest NEXT OverallAverage « Overalirotal/10 PRINT "Overall Average is ", Overellaverage [PRINT ‘overall Highest Mark is *, OverallRighest RINT "Overall Lowest Mark is ", OveraliLowest: b Test data © Dataset 1: 20, 30, 40, 50, 60, 10, 30,40,50,70 normal data @ Data set 2: 0,0, 0, 0, 0,100, 100, 100,100,100 accepted boundary data @ Data set 3: -1, LOL rejected boundary data @ Daraset 4: A,-20, 190 erroneous data IGCSE Computer Science Teacher's CD © David Watson & Helen Williams 2015

You might also like