#include <iostream>
#include <conio.h>
using namespace std;
int main ()
{
float income;
float distance;
int TripsCounter = 0;
float TotalIncome = 0;
float TotalDistance = 0;
float TheShortestTrip = 1000000 ;
cout<<"Hello dear driver"<<endl;
while (TotalIncome<300)
{
cout<<"Please, enter the income of the trip ($): ";
cin>>income;
cout<<"Please, enter the distance of the trip (km): ";
cin>>distance;
TripsCounter++;
TotalIncome += income;
TotalDistance += distance;
if (distance < TheShortestTrip)
TheShortestTrip = distance;
}
cout<<"So today you have made "<<TripsCounter<<" trips"<<endl;
cout<<"Total distace is: "<<TotalDistance<<" km"<<endl;
cout<<"The shortest trip is "<<TheShortestTrip<<" km"<<endl;
_getch();
return 0;
}
Comments
Leave a comment