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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
class Time;
int main() //This is the Main Method
{
string car1, car2, car3;
string time1, time2, time3;
string color1, color2, color3;
cout << "Welcome Enter the name of the racers, their time, and car color.\n Seperate name and time with a space.";
//Enter information for Car 1
cout << "Who is driving Car 1?" << endl;
cin >> car1;
cout << "What is the time of Car 1?" << endl;
cin >> time1;
cout << "What is the color of Car 1?" << endl;
cin >> color1;
//Enter information for Car 2
cout << "Who is driving Car 2?" << endl;
cin >> car2;
cout << "What is the time of Car 2?" << endl;
cin >> time2;
cout << "What is the color of Car 2?" << endl;
cin >> color2;
//Enter information for Car 3
cout << "Who is driving Car 3?" << endl;
cin >> car3;
cout << "What is the time of Car 3?" << endl;
cin >> time3;
cout << "What is the color of Car 3?" << endl;
cin >> color3;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
//THIS PIECE OF CODE REQUESTS INPUT OF CRITERIA ALL ON SAME LINE
//cout << "\n Enter the name of racer 1, time, and car color: ";
//cin >> car1 >> time1 >> color1;
//cout << " Enter the name of racer 2, time, and car color: ";
//cin >> car2 >> time2 >> color2;
//cout << " Enter the name of racer 3, time, and car color: ";
//cin >> car3 >> time3 >> color3;
//cin.clear();
//cin.ignore(numeric_limits<streamsize>::max(), '\n');
{ //check if car1 came in first
if(time1 < time2 && time1 < time3)
{
if(time1 < time2) //if he did, then check to see where car2 and car3 placed
{
cout << car1 << color1 << " came in first with a score of " << time1 << endl;
cout << car2 << color2 <<" came in second with a score of "<< time2 << endl;
cout << car3 << color3 <<" came in third with a score of "<< time3 << endl;
}
else
{
cout << car1 << color1 << " came in first with a score of "<< time1 << endl;
cout << car3 << color3 << " came in second with a score of "<< time3 <<endl;
cout << car2 << color2 << " came in third with a score of "<< time2 << endl;
}
}
}
{ // check if car2 came first
if(time2 < time1 && time2 < time3)
{
if(time1 < time3) //if he did, then check to see where car1 and car3 placed
{
cout << car2 << color2 << " came in first with a score of "<< time2 << endl;
cout << car1 << color1 << " came in second with a score of "<< time1 << endl;
cout << car3 << color3 << " came in third with a score of "<< time3 << endl;
}
else
{
cout << car2 << color2 << " came in first with a score of "<< time2 << endl;
cout << car3 << color3 << " came in second with a score of "<< time3 << endl;
cout << car1 << color1 << " came in third with a score of "<< time1 << endl;
}
}
}
{ // check if car3 came first
if(time3 < time1 && time3 < time2)
{
if(time2 < time1) //if he did, then check to see where car1 and car2 placed
{
cout << car3 << color3 << " came in first with a score of "<< time3 << endl;
cout << car2 << color2 << " came in second with a score of "<< time2 << endl;
cout << car1 << color1 << " came in third with a score of "<< time1 << endl;
}
else
{
cout << car3 << color3 << " came in first with a score of "<< time3 << endl;
cout << car1 << color1 << " came in second with a score of "<< time1 << endl;
cout << car2 << color2 << " came in third with a score of "<< time2 << endl;
return 0;
}
}
}
system("PAUSE");
return EXIT_SUCCESS;
}
|