Using 5k pace and ordering them in first,second and third place

Hi guys I need some assistance with a C++ code. I am very new to C++ and coding in general and I am stuck on this assignment. We are given a person's name, bib, gender, and their 5k time in minutes and seconds. We have to write a code that calculate their pace in minutes per mile and rank them in first second and third place. What I think is my main problem(hopefully) is creating an if/then statement that determines the rankings of the runners. Thank you for the help! Here is my code so far:

#include "race.h"
#include <string>

using namespace std;

void displayRunnerInfo(string Name, int Bib, string Age, int Gender, string Minutes, int Seconds, ofstream& out)
{

out << Name << Bib << Age << Gender << Minutes << Seconds;

}
void readData(istream& in, string &Name, int &Bib, int &Age, string &Gender, int &Minutes, int &Seconds)
{
getline(in, Name, ',');
in >> Bib;
in >> Age;
getline(in, Gender, ',');
in >> Minutes;
in >> Seconds;
}

using std::string;

void raceResults(std::string input,std::string output)
{
ifstream in(input);
ofstream out(output);
string Name;
double totalSeconds;
int Bib = 0;
int Age = 0;
string Gender;
int Minutes = 0;
int Seconds = 0;
string Time;
int totalDistance = 3.1;
int pace = 0;
string First;
string Second;
string Third;


std:: string header;
getline(in, header);
out << header << endl;
in.ignore(5000, '\n');

readData(in, Name, Bib, Age, Gender, Minutes, Seconds);
while (!in.fail())
{
totalSeconds = ((Minutes * 60) + Seconds)/60);// this converts total time into seconds
if (totalSeconds > 0)
{
pace = floor(totalSeconds/ totalDistance);// formula to find the pace
out << Name << Bib << Age << Gender << pace << endl;//new output
}

}
}
out << "First:" << '\t' << First << '\t' << Time << '\t' << pace << endl;
out << "Second:" << '\t' << Second << '\t' << Time << '\t' << pace << endl;
out << "Third:" << '\t' << Third << '\t' << Time << '\t' << pace << endl;
}
readData(in, Name, Bib, Age, Gender, Minutes, Seconds);
}
Please use code tags:
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
#include "race.h"
#include <string>

using namespace std;

void displayRunnerInfo(string Name, int Bib, string Age, int Gender, string Minutes, int Seconds, ofstream& out)
{

out << Name << Bib << Age << Gender << Minutes << Seconds;

}
void readData(istream& in, string &Name, int &Bib, int &Age, string &Gender, int &Minutes, int &Seconds)
{
getline(in, Name, ',');
in >> Bib;
in >> Age;
getline(in, Gender, ',');
in >> Minutes;
in >> Seconds;
}

using std::string;

void raceResults(std::string input,std::string output)
{
ifstream in(input);
ofstream out(output);
string Name;
double totalSeconds;
int Bib = 0;
int Age = 0;
string Gender;
int Minutes = 0;
int Seconds = 0;
string Time;
int totalDistance = 3.1;
int pace = 0;
string First;
string Second;
string Third;


std:: string header;
getline(in, header);
out << header << endl;
in.ignore(5000, '\n');

readData(in, Name, Bib, Age, Gender, Minutes, Seconds);
while (!in.fail())
{
totalSeconds = ((Minutes * 60) + Seconds)/60);// this converts total time into seconds
if (totalSeconds > 0)
{
pace = floor(totalSeconds/ totalDistance);// formula to find the pace
out << Name << Bib << Age << Gender << pace << endl;//new output
}

}
}
out << "First:" << '\t' << First << '\t' << Time << '\t' << pace << endl;
out << "Second:" << '\t' << Second << '\t' << Time << '\t' << pace << endl;
out << "Third:" << '\t' << Third << '\t' << Time << '\t' << pace << endl;
}
readData(in, Name, Bib, Age, Gender, Minutes, Seconds);
}
Topic archived. No new replies allowed.