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

An F1 car can achieve a lap time of 1 min 29.28 seconds at the Bahrain Grand Pri

ID: 3718549 • Letter: A

Question

An F1 car can achieve a lap time of 1 min 29.28 seconds at the Bahrain Grand Prix. At the start of the race, the hybrid 6 cylinders based F1 race car has 100kg of fuel. For every 10kg of flue the car uses, the lap time goes down 0.20 sec. For every lap, the tires degrade and the lap time increases 0.05 sec per lap. For the race one this circuit, the car will average 7.25 Miles per Gallon. Write a program C++ that will determine the car's theoretical lap time on any of the 57 laps of the race. you are to use a class with all variables in the private portion of the class. A header (.H) file is required. Key values: 1Gallon of fuel =2.99Kg 57 Laps at 5.412 km/lap Total race distance is 308.484 km 1km = 0.621 miles 1mile = 1.609km Hint: Create an activity or flowchart and come up with the equation for tire wearing down, an equation for fuel before coding.

Explanation / Answer

according to the information given (linear relationship have been assumed)

1)there is enough fuel for 57 laps. (you can go 390.14 km using the info 7.25 miles per gallon thing)

2)time per km decreases by 0.005126 sec (according to 0.2 sec per 10 kg which give 0.2 sec 39.014 km since you can go 3.9014 km per kg of fuel )

3)time per km increases by 0.0092 sec (due to tyre wear since it is 0.05/5.412 )

i am giving the header, the source and the main file

header file( f1_car.h )

#ifndef car_h

#define car_h

class f1_car{

int fuel; //initial fuel in kg

float fuel_speed_increase; // decrease in time per km due to fuel

float distance_speed_decrease; //increase in time per km to wear

public:

f1_car();

float get_lap_time(int lap);

};

#endif

source file( car_source.cpp)

#include "f1_car.h"

f1_car::f1_car(){

fuel=100;

fuel_speed_increase=-0.0051;

distance_speed_decrease=0.0092;

}

float f1_car::get_lap_time(int lap){

// total km

float km=lap*5.412;

// find decrease in time due to less fuel

float d=fuel_speed_increase*km;

float i=distance_speed_decrease*km;

float tot_time=89.28+d+i;

return tot_time;

}

main file ( main.cpp)

#include<iostream>

#include "f1_car.h"

#include "car_source.cpp"

using namespace std;

int main(){

int lap;

cout<<"enter lap no ";

cin>>lap;

//make an instance of f1_car

f1_car car;

float total_time;

total_time=car.get_lap_time(lap);

int time_in_min=(int)total_time/60;

float time_in_sec=total_time-time_in_min*60;

cout<<"total time is "<<time_in_min<<" min and "<<time_in_sec<< "second ";

}