Task 11 - Speeding

Description of problem

An insurance company is conducting a survey to determine whether drivers of newer cars are more likely to break the speed limit than drivers of older cars. An employee of the insurance company will sit with a tablet besides a speed warning sign. When the warning sign lights up, the employee will record that the car was breaking the speed limit. If the warning sign does not light up, the employee will record that the car was not breaking the speed limit.

The age of the car will also be recorded for all cars. A program is required to store this information and analyse the results.

Functional requirements

The required program should:

  • Read in previously recorded data from a text file when the program starts. If no previous data exists, the program should create an empty text file. You can design the text file structure you would like to use for this task, however an example is given in inputs.
  • Ask the user to continually enter each cars age and speeding data until the user enters 999 for the age. The data for each car should be added onto the previously recorded data.
  • Display the percentage of cars that were breaking the speed limit.
  • Display a list of car ages showing how many of each age were caught speeding.
  • Display the age of car that was caught speeding more times than any other age of car.
  • Before the program finishes executing, the up-to-date data should be written back to the text file, overwriting the previous data.

Inputs

The program should receive the following inputs:

  • Car data from the file will be inputted with the following format: age, speed, end-of-line for example: 10,1/n
  • A cars age in years should be entered as an integer value
  • If a car was speeding a value of 1 should be recorded, if they were not speeding a value of 0 should be recorded