Photo AI

A car manufacturer includes an event data recorder in their cars - Scottish Highers Computing Science - Question 11 - 2019

Question icon

Question 11

A-car-manufacturer-includes-an-event-data-recorder-in-their-cars-Scottish Highers Computing Science-Question 11-2019.png

A car manufacturer includes an event data recorder in their cars. This device begins recording when the car's sensors detect a sudden change in speed. The data captu... show full transcript

Worked Solution & Example Answer:A car manufacturer includes an event data recorder in their cars - Scottish Highers Computing Science - Question 11 - 2019

Step 1

State two boundaries for this task.

96%

114 rated

Answer

  1. The boundaries for the acceleration values, which must range between 0% and 100%.
  2. The boundaries for the speed, which must have a minimum of 0 mph and the maximum dependent on the car's specifications.

Step 2

Using a programming language of your choice, define a suitable record data structure for the data above.

99%

104 rated

Answer

class CarData:
    def __init__(self):
        self.speed = 0.0  # Speed in mph
        self.accelerator = 0  # Accelerator percentage
        self.brake = 0  # Brake percentage
        self.seatbelt = False  # Seatbelt status

Step 3

Using a programming language of your choice, define the variable which can store the details of the 200 readings.

96%

101 rated

Answer

readings = [CarData() for _ in range(200)]

Step 4

Using a recognised design technique, design an algorithm to find the maximum speed.

98%

120 rated

Answer

  1. Initialize max_speed to 0.
  2. Loop through each reading in readings.
    • If reading.speed > max_speed, then:
      • Set max_speed to reading.speed.
  3. End Loop.
  4. Return max_speed.

Join the Scottish Highers students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;