Overloaded Opeartor

So I finished my code, however, it doesn't seem right to me and there may be something off with the Average Times. I need another set of eyes to see if the average time makes sense in the display function. It works just fine but something seems off and I can't quite catch it. Any assistance would be much appreciated. This display function is utilized as a FRIEND function.

void display(RacingData& Avg, RacingData& AVG)
{
cout << "*****Racer Average Score & Time***** " << endl << endl;
cout << " Danica's Average Score is " << Avg.score/3 << endl;
if (Avg.seconds >= 60)
{
Avg.minutes += Avg.seconds /60;
Avg.seconds = Avg.seconds % 60;
cout << " Danica's Average Time is " << Avg.minutes/3 << " Minutes " << Avg.seconds/3 << " Seconds " << endl << endl;
}

cout << " Jeff's Average Score is " << AVG.score/3 << endl;
if (AVG.seconds >= 60)
{
AVG.minutes += AVG.seconds / 60;
AVG.seconds = AVG.seconds % 60;
cout << " Jeff's Average Time is " << AVG.minutes/3 << " Minutes " << AVG.seconds/3 << " Seconds " << endl << endl;
}

cout << "*****Racer Results***** " << endl << endl;
if (Avg.score > AVG.score)
{
cout << " The Highest TOTAL Score: " << Avg.name << endl << endl;
}
else
{
cout << " The Highest TOTAL Score: " << AVG.name << endl << endl;
}

if (Avg.minutes && Avg.seconds > AVG.minutes && AVG.seconds)
{
cout << " The Lowest TOTAL Time: " << Avg.name << endl << endl;
}
else
{
cout << " The Lowest TOTAL Time: " << AVG.name << endl << endl;
}

}
Last edited on
Your average time calculations aren't correct...I would just keep it all in seconds, get the average, and then convert to minutes/seconds.
Can you give me an example out of this? I'm not following on your idea of conversion to seconds.

Thanks~
Okay, so I changed some things around but want you guys to take a look at it to see if it makes sense~

void display(RacingData& Avg, RacingData& AVG)
{
cout << "*****Racer Average Score & Time***** " << endl << endl;
cout << " Danica's Average Score is " << Avg.score/3 << endl;
Avg.minutes = Avg.minutes/3;
Avg.seconds = Avg.seconds/3;
cout << " Danica's Average Time is " << Avg.minutes << " Minutes " << Avg.seconds << " Seconds " << endl << endl;


cout << " Jeff's Average Score is " << AVG.score/3 << endl;
AVG.minutes = AVG.minutes/3;
AVG.seconds = AVG.seconds/3;
cout << " Jeff's Average Time is " << AVG.minutes << " Minutes " << AVG.seconds << " Seconds " << endl << endl;


cout << "*****Racer Results***** " << endl << endl;
if (Avg.score > AVG.score)
{
cout << " The Highest TOTAL Score: " << Avg.name << endl << endl;
}
else
{
cout << " The Highest TOTAL Score: " << AVG.name << endl << endl;
}

if (Avg.minutes && Avg.seconds > AVG.minutes && AVG.seconds)
{
cout << " The Lowest TOTAL Time: " << AVG.name << endl << endl;
}
else
{
cout << " The Lowest TOTAL Time: " << Avg.name << endl << endl;
}

}
Topic archived. No new replies allowed.