Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to write a program for times that a car goes around a track. My initial l

ID: 3563972 • Letter: I

Question

I need to write a program for times that a car goes around a track.

My initial lap time (for lap 1) is 72.142 sec.

** Due to tire degredation, (I slow down) 0.5 seconds is added to my time after each lap. I have my for loop set up, but I don't know how to write this equation. I wrote "laptime = laptime + 0.5" But when I run the program it displays lap 1 as 72.642 sec. How do I leave the lap 1 time alone and have it start adding on lap 2?

** And then every lap uses 2.5 kg fuel. And for every 10kg I use (I speed up) 0.35 sec will be taken off my time. So every four laps. How would I write this equation?

Explanation / Answer

Use an array.. Say the car goes 20 rounds.. Then the equation will be like..

float time[20];

int j=1,i=1;

time[0] = 72.142;

while(j<=20)

{

i++;

if(i%4!=0)

{

   time[j] = time[j-1]+0.5;

  

}

else if(i%4==0)

{

  time[j] = time[j-1]+0.15;

i=0;

}

j++;

}