Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

A circuit race contains 50 cars to race the circuit

for two laps. The lap times are recorded in the 2D array
called "Check[]" and the car number plates are stored in the
dimensional array called "Plate[]".
-calculate and store the average times for each car.
-calculate and store the total lap time for each car.
-output the plate number and lap times of the Winner
-output the last checked in cars for the first lap
and the second lap
_______________________________________________________
Sample data structure:

Plate = ["AA-1111", "BB-2222", "CC-3333", "DD-4444",...]


Check = [[4.6,3.58], [3.47,5.21], [4.44,4.21], [5.13,3.27],...]

_______________________________________________________
Pseudocode
Plate []
Check []
Average_Time [] #Array to store
the average times for every car
Total_Time [] #Array to store
the total times for every car

FOR index1 <-1 TO 50 #Iteration


required for calculations for each and every car
Average_Time[index1] <-- (Check[index1][1]+Check[index1][2])/2 #Calculation of
average time and at the same time storing in data
Total_Time[index1] <-- Check[index1][1]+Check[index1][2] #Calculation of
total time and at the same time storing in data

winner_total_times <-- Total_Time[1] #Setting the


winner_total_times as a reference to compare with the data in array for each
position
IF winner_total_times > Total_Time[index1] THEN
winner_total_times <-- Total_Time[index1]
winner <-- Plate[index1]
winner_lap_1_times <-- Check[index1][1]
winner_lap_2_times <-- Check[index1][2]

last_checked_time1 <-- Check[index1][1]


last_checked_time2 <-- Check[index1][2]
IF Check[index1][1] > last_checked_time1 THEN
last_checked_time1 <-- Check[index1][1]
last_checked_car1 <-- Plate[index1]
IF Check[index1][2] > last_checked_time2 THEN
last_checked_time2 <-- Check[index1][2]
last_checked_car2 <-- Plate[index1]
NEXT index1

PRINT Plate
PRINT Average_Time
PRINT Total_Time
PRINT "The winner", winner, "won with lap 1 time of", winner_lap1_times, "and lap 2
time of", winner_lap2_times
PRINT " Last checked in for lap 1 is plate number:", last_checked_car1 ,"and check
time:",last_checked_time1
PRINT " Last checked in for lap 2 is plate number:", last_checked_car2 ,"and check
time:",last_checked_time2

You might also like