SW 2023
SW 2023
9 on 17/01/2023 11:1
Program analysis
At the end of the journey, details are submitted to EVcharge to calculate the final cost.
Inputs
♦ The vehicle mileage at the start of the
journey.
♦ The number of charging stations visited.
♦ A valid kilowatt (kW) rating for each
charging station (7kW, 22kW or 50kW).
♦ The vehicle mileage at each charging
station.
For example, if making the journey from Aberdeen to Dumfries via Stirling (shown in the
diagram below), the user would enter:
Version 1.0 13
ownloaded by [email protected] from 217.181.30.9 on 17/01/2023 11:1
Process
♦ Calculate the number of miles travelled in each stage of the journey.
♦ Calculate the cost of each stage of the journey using the number of miles travelled and
the cost per mile, based on the kW rating of the charging station as shown below:
— 7kW = £0 per mile
— 22kW = £0.005 per mile
— 50kW = £0.01 per mile
♦ Calculate the total number of miles travelled from the start to the end of the journey.
♦ Calculate the total cost for the journey.
Outputs
♦ The total number of miles travelled.
♦ The cost (£) of each stage of the journey.
♦ The total cost (£) rounded to two decimal places.
Assumption(s)
♦ The user will complete the journey using no more than 10 charging stations.
Version 1.0 14
ownloaded by [email protected] from 217.181.30.9 on 17/01/2023 11:1
Using the information provided in the program analysis, design how this process could
be carried out. You can use a flowchart, structure diagram or pseudocode design.
(3 marks)
♦ Check your answers carefully, as you cannot return to part A after you hand it in.
♦ When you are ready, hand part A to your teacher or lecturer and collect part B.
Version 1.0 15
ownloaded by [email protected] from 217.181.30.9 on 17/01/2023 11:1
Main steps
Version 1.0 16
ownloaded by [email protected] from 217.181.30.9 on 17/01/2023 11:1
Refinement of ‘Calculate and store the cost of each stage of the journey’
Refinement of ‘Display total miles, journey stage costs and total cost’
Version 1.0 17
ownloaded by [email protected] from 217.181.30.9 on 17/01/2023 11:1
1b Using the program analysis and the design, implement the program in a language of
your choice.
(15 marks)
Print evidence of your program code.
1c(i) Your program should be tested to ensure it produces the correct output.
Use the test data provided below to check that your program produces the correct
output.
(1 mark)
Version 1.0 18
ownloaded by [email protected] from 217.181.30.9 on 17/01/2023 11:1
(ii) In the test data below, the mileage entered at Charge station 2 is not correct.
Complete the test table below — this will show that the program is not fit for
purpose.
(2 marks)
(iii) With reference to the test data above, describe how to make the program fit for
purpose.
(1 mark)
Version 1.0 19
ownloaded by [email protected] from 217.181.30.9 on 17/01/2023 11:1
1d With reference to your code, evaluate your program by commenting on the following:
Version 1.0 20