1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include <iostream>
#include <cmath>
using namespace std;
double totalDistance (double V, double T);
const double fuelConsumed (double V, double T);
int lapsCompleted (double R, double V, double T);
double remainingDistance (double R, double V, double T);
int main () {
double R;
double V;
double T;
double totalDistance = V * T;
const double fuelConsumed = 0.25 * totalDistance;
int lapsCompleted = (V * T) / (2*3.14*R);
double remainingDistance = (V * T) % (2*3.14*R);
cout << "Enter the Radius of the circular path in km:";
cin >> R;
cout << "Enter the speed of the car in km/h: ";
cin >> V;
cout << "Enter the Time of the race in hours: ";
cin >> T;
cout << "The total distance traveled was: ";
cout << totalDistance (V,T);
cout << " km.";
cout << "The amount of fuel consumed was: ";
cout << fuelConsumed (V,T);
cout <<" L.";
cout << "The driver completed:";
cout << lapsCompleted (V, T, R);
cout <<"Laps.";
cout << "The remaining distance to the finish line is: ";
cout << remainingDistance (V, T, R);
cout << "km. \n";
return 0;
}
double totalDistance (double V, double T)
{
return V*T;
}
const double fuelConsumed (double V, double T)
{
return 0.25*V*T;
}
int lapsCompleted (double V, double T, double R)
{
return (V*T) /(2*M_PI*R);
}
double remainingDistance (double R, double V, double T)
{
return (V*T)%(2*3.14*R);
}
|