13 A function is being developed to calculate information about visits to Edinburgh Castle on particular days depending on the weather. a The function will make use of formal Formal parameters are the identifiers used to and actual parameters. Explain each of stand for a value that will be passed when a these terms. subprogram/method is called (such as myparameter). (1 mark) Actual parameters are the actual values passed to a subprogram/method at runtime (such 12). (1 mark) 2 b Explain how a method is different from A method is a subroutine within an object a function. in OOP. It is defines an object’s behaviour (at run time). A function is not part of an object and functions independently in a programme. Any one bullet for 1 mark 2 c Visitor statistics are recorded for the 1. SET sunnyvar TO 0 previous 28 days. For each day, the 2. FOR counter = 1 TO 28 statistics include the number of visitors 3. IF visitors[counter] > 5000 on that day and the number of hours of hours_of_sunshine[counter] >= 6 THEN sunshine. 4. SET sunnyvar TO sunnyvar + 1 5. END IF Some of the data is shown below: (see 6. END FOR paper) 7. OPEN sunnydays 8. SEND sunnyvar TO sunnydays The number of visitors for each day is 9. CLOSE sunnydays held in an called and visitors Answer can be in any language or form the number of hours of sunshine in of pseudocode. Using pseudocode or a sunhours. language with which you are familiar, 1 mark for each of any five of the following: write an algorithm to count the number initialise and increment sunnyvar of days where the visitor count was the FOR loop with END FOR greater than 5000 and there were 6 or IF construct with END IF more hours of sunshine and write this correct complex condition with two number of days to a text file called variables sunnydays. OPEN and CLOSE 5
13 A function is being developed to calculate information about visits to Edinburgh Castle on particular days depending on the weather. a The function will make use of formal and actual parameters. Explain each of these terms. Formal parameters are the identifiers used to stand for a value that will be passed when a subprogram/method is called (such as myparameter). (1 mark) Actual parameters are the actual values passed to a subprogram/method at runtime (such 12). (1 mark) 2 b Explain how a method is different from a function. A method is a subroutine within an object in OOP. It is defines an object’s behaviour (at run time). A function is not part of an object and functions independently in a programme. Any one bullet for 1 mark 2 c Visitor statistics are recorded for the previous 28 days. For each day, the statistics include the number of visitors on that day and the number of hours of sunshine. Some of the data is shown below: (see paper) The number of visitors for each day is held in an called visitors and the number of hours of sunshine in sunhours. Using pseudocode or a language with which you are familiar, write an algorithm to count the number of days where the visitor count was greater than 5000 and there were 6 or more hours of sunshine and write this number of days to a text file called sunnydays. 1. SET sunnyvar TO 0 2. FOR counter = 1 TO 28 3. IF visitors[counter] > 5000 hours_of_sunshine[counter] >= 6 THEN 4. SET sunnyvar TO sunnyvar + 1 5. END IF 6. END FOR 7. OPEN sunnydays 8. SEND sunnyvar TO sunnydays 9. CLOSE sunnydays Answer can be in any language or form of pseudocode. 1 mark for each of any five of the following: initialise and increment sunnyvar the FOR loop with END FOR IF construct with END IF correct complex condition with two variables OPEN and CLOSE 5