I am working on a program right now to determine whether a not a person participating in a race qualifies for the next round based on their age and the time it took them to complete the first race. I am not sure if I am correctly coding the function to do just that so any input on what I can do what be greatly appreciated. Also I need to keep count of the people that do qualify, the numbers are coming from a data file that I am reading in.
//Qualify function recieves age and time and determines if they qualify
int Qualify(int age, int time)
{
//Variables
i=0;
string qualifies;
string not;
do
while (i != -1)
{
if (age < 30 && time <=300) // Checks age and time
{
cin >> qualifies;
else if (age <30 && time >300)
cin >> not;
}
if (age >= 30 && age <= 50 && time <= 360)
{
cin >> qualifies;
else if (age >=30 && age <= 50 && time >360)
cin >> not;
}
if (age > 50 && time <= 420)
{
cin >> qualifies;
else
cin >> not;
}
}
(this is just the function, the infile call is in the main function)
I wasn't quite sure what you asked. But i 100% think it is this...
And i saw your function beginning with big letter... Remember C++ is case-sensitive...What is "do" doing here?
Yeah sorry I tried to be as clear as possible, but this really did help alot, I realize I needed a participants variable and how to keep count of them most importantly.
So here is my next problem, I am reading in data from a file and it is age, and race time. throughout the data they switch which side the race time and age is on, (like this)
I need a function that understands that the bigger number is the race time, this is what I have.
void CheckAgeTime(int &age, int &time)
{
while (i != -1)
{
i=0;
if (age > time)
{
swap(age,time);
else
}
}
}
Pretty sure this is not right, but its really all I have come up with.
this is the last part of my program that needs fixed, so any pointers on how to set up this function would be great, Thanks again.