0% found this document useful (0 votes)
28 views

Circuit Race

The document describes a circuit race with 50 cars that each complete 2 laps. It provides pseudocode to: 1) calculate and store the average and total times for each car, 2) identify the overall winner and their individual lap times, and 3) output the last checked cars for each lap along with their times. Sample data structures of car plate numbers and lap times are provided.

Uploaded by

Ar Rati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Circuit Race

The document describes a circuit race with 50 cars that each complete 2 laps. It provides pseudocode to: 1) calculate and store the average and total times for each car, 2) identify the overall winner and their individual lap times, and 3) output the last checked cars for each lap along with their times. Sample data structures of car plate numbers and lap times are provided.

Uploaded by

Ar Rati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy