A car manufacturer is creating a car concept. A variety of funcitons will be controlled by buttons on the dashboard

The driver can push items on a digital menu:

  1. View speed
  2. View speed history
  3. Update speed history
  4. View date
  5. View mileage
  6. Open windows
  7. Close windows
  8. Aircon

The following identifier table for global variables used in the system has been created

Identifier Data Type Description
currentSpeed INTEGER the current speed of the car
speedHistory ARRAY[1:10] OF INTEGER randon samples of speed during the last hour of driving
dateToday DATE today's date
windowStatus BOOLEAN the current status of the windows - open or close
airconStatus BOOLEAN the current status of the aircon - on or off

 

PROCEDURE viewSpeed() - displays the current speed
PROCEDURE viewSpeedHistory() - displays the 10 speed samples, and also displays the average speed, max speed and min speed value.
FUNCTION updateSpeedHistory(index:INTEGER, newValue:INTEGER) RETURNS BOOLEAN - updates the speedHistory array with newValue at index. If newValue is the same as the current value, it returns FALSE, otherwise it returns TRUE
PROCEDURE viewDate() - displays today's date.
PROCEDURE viewMileage() - displays the car's mileage.
FUNCTION openWindows() RETURNS BOOLEAN - The function simply returns TRUE
FUNCTION closeWindows() RETURNS BOOLEAN - The function simply returns FALSE
FUNCTION updateAircon() RETURNS STRING - updates the airconStatus and returns a sentence stating the current status eg "The aircon is now on!".

 

 

Set up the global variables.

Design each module and test your program by translating the test code into program code.

The Driving Seat

You are in the driving seat! You are the program designer. Use your skills to solve the problem.