Note AcademyNote Academy

Computer Science · Oct / Nov 2023 · Paper 21 · Question 8

0478

As printed in the paper

The question as text

A programmer is designing an algorithm to calculate the cost of a length of rope. The program requirements are: • input two values: the length of rope in metres Length and the cost of one metre Cost • perform a validation check on the length to ensure that the value is between 0.5 and 6.0 inclusive • calculate the price Price • output the price rounded to two decimal places. Use the variable names given.

Read automatically from the paper; the printed page above is exact.

Show the answer and mark scheme
  • 8(a)[1]

    Range check

  • 8(b)[6]

    One mark for each of the following points

    START

    correct use of flowchart symbols
    working flow lines and complete
    both inputs correct

    INPUT Length

    working range check
    working calculation
    correct output rounded to two decimal places

    Is Length >=0.5

    No

    AND Length <=

    6.0 ?

    Yes

    INPUT Cost

    Price ← Length * Cost

    OUTPUT

    "Price ",

    ROUND(Price,2)

    STOP

  • 8(c)[4]

    One mark for set of test data, one mark for purpose (max four)

    Example:

    1 and 1 (1) normal data to ensure the algorithm accepts this test data (1)

    –1 and 1 (1) abnormal data for length to ensure that it is rejected (1)

  • 8(d)[3]

    One mark for two correct headings

    Two marks for three correct headings

    Three marks for all headings correct and no other headings unless used in 8(b)

    Length

    Cost

    Price

    OUTPUT

  • 8(e)[2]

    One mark for each point (max two)

    validate Cost …
    … with a range/presence check
    add another validation check for Length

Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.