Jun 9, 2019 at 5:02pm UTC
Hi guys, this is not showing the second place!!
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
using namespace std;
int main() {
string runner1 = "";
string runner2 = "";
string runner3 = "";
double timeR1 = 0.0;
double timeR2 = 0.0;
double timeR3 = 0.0;
string first = "";
string second = "";
string third = "";
cout << "Runner 1 name: ";
cin >> runner1;
cout << "Runner 1 Time: ";
cin >> timeR1;
cout << "Runner 2 name: ";
cin >> runner2;
cout << "Runner 2 Time: ";
cin >> timeR2;
cout << "Runner 3 name: ";
cin >> runner3;
cout << "Runner 3 Time: ";
cin >> timeR3;
while (timeR1 < 0 || timeR2 < 0 || timeR3 < 0)
{
cout << " ***Time can not be negative.***\n "
<< "***Please enter a positive number when prompt***" << endl;
cout << "Runner 1 name: ";
cin >> runner1;
cout << "Runner 1 Time: ";
cin >> timeR1;
cout << "Runner 2 name: ";
cin >> runner2;
cout << "Runner 2 Time: ";
cin >> timeR2;
cout << "Runner 3 name: ";
cin >> runner3;
cout << "Runner 3 Time: ";
cin >> timeR3;
}
if (timeR1 < timeR2 && timeR1 < timeR3)
{
first = runner1;
}
else if (timeR1 < timeR2 && timeR1 > timeR3)
{
second = runner1;
}
else if (timeR1 > timeR2 && timeR1 > timeR3)
{
third = runner1;
}
if (timeR2 < timeR1 && timeR2 < timeR3)
{
first = runner2;
}
else if (timeR2 < timeR1 && timeR2 > timeR3)
{
second = runner2;
}
else if (timeR2 > timeR1 && timeR2 > timeR3)
{
third = runner2;
}
if (timeR3 < timeR1 && timeR3 < timeR2)
{
first = runner3;
}
else if (timeR3 < timeR1 && timeR3 > timeR2)
{
second = runner3;
}
else if (timeR3 > timeR1 && timeR3 > timeR2)
{
third = runner3;
}
cout << "The Winner is: " << first << endl;
cout << "The second place is: " << second << endl;
cout << "The third place is: " << third << endl;
system("pause");
return 0;
}