When I compile this it skips the over my error checking and ends the program. Can anyone point out what I am doing wrong?
#include <iostream>
#include <string>
using namespace std;
int main()
{
/*
Write a program that asks for the names of three runners and the time it took each of them to finish a race. The program should display who came in first, second, and third place. Think about how many test cases are needed to verify that your problem works correctly. (That is, how many different finish orders are possible?)
*/
string racer1, racer2, racer3;
double r1, r2, r3;
cout << "Enter the name of Racer 1: ";
getline(cin, racer1);
cout << "Enter the name of Racer 2: ";
getline(cin, racer2);
cout << "Enter the name of Racer 3: ";
getline(cin, racer3);
cout << endl;
cout << "Enter the time for " << racer1 << " : ";
cin >> r1;
cout << "Enter the time for " << racer2 << " : ";
cin >> r2;
cout << "Enter the time for " << racer3 << " : ";
cin >> r3;
cin.ignore();
I threw in some output statements to trace where the code was going in the nested ifs. There's at least one case where the times get picked up in one of the else ifs but gets disqualified from the cout statements.
Are you listing the person with the longest time first or the shortest time first?
Enter the name of Racer 1: r1
Enter the name of Racer 2: r2
Enter the name of Racer 3: r3
Enter the time for r1 : 500
Enter the time for r2 : 550
Enter the time for r3 : 600
r2>r1
Thanks! I just had to changed the all the "Greater than" signs to "Lesser than." I realized that I was looking to display the shortest time, when my coding was actually trying to sort for the longest. So the time inputs did not fall under any of the conditions given. Thanks again!