I've been trying to think of the easiest way to calculate the average and display the results.

The two outputs that I am missing would be the average part of the program. When the program is ran, it should display
"Danika Patrick averaged a score of 120 in 11 minutes and 10 seconds."
"Jeff Gordon averaged a score of 105 in 11 minutes and 0 seconds."
+ the int main cout that is already included in my code.

Any suggestions on what you guys would do would work. I'm supposed to follow the step below:

2. USING THE OVERLOADED + OPERATOR, find the average score and time for each player and print out which
performer had the lowest total time, and which performer had the highest total score.

#include <iostream>
#include <string>
using namespace std;

class RacingData
{
public:
	RacingData();
	RacingData(string, int, int, int);
	void setData(string newName, int newScore, int newMinutes, int newSeconds);
	void getData(string &_name, int &_score, int &_minutes, int &_seconds);
	void printData() const;
	RacingData operator+(RacingData &other) const;
private:
	string name;
	int score, minutes, seconds;
};

RacingData::RacingData() { name = " "; score = minutes = seconds = 0; }
RacingData::RacingData(string newName, int newScore, int newMinutes, int newSeconds) { name = newName; score = newScore; minutes = newMinutes; seconds = newSeconds; }

void RacingData::setData(string newName, int newScore, int newMinutes, int newSeconds)
{
	name = newName;
	score = newScore;
	minutes = newMinutes;
	seconds = newSeconds;
}
void RacingData::getData(string &_name, int &_score, int &_minutes, int &_seconds)
{
	_name = name;
	_score = score;
	_minutes = minutes;
	_seconds = seconds;
}

void RacingData::printData() const
{
	 cout << name << " scored a total of " << score << " points in a total of " << minutes << " minutes and " << seconds << " seconds." << endl;
}
 
RacingData RacingData::operator+(RacingData &other) const
{
	string dummyString;//holds a name of the obj
	int otherScore, otherMinutes, otherSeconds; // holds values of all 3 data members of object other
	RacingData newObject; //holds data
	other.getData(dummyString, otherScore, otherMinutes, otherSeconds);//gets all 3 data members
	newObject.setData(name, score + otherScore, minutes + otherMinutes, seconds + otherSeconds);
	//add the total of the implicit obj to the explicit obj other and save the total to obj newObject
	
	//make sure any other excessive minutes gets rolled over to hours
	newObject.getData(dummyString, otherScore, otherMinutes, otherSeconds);
	if (otherSeconds > 59)
	{
		otherMinutes = otherMinutes + (otherSeconds / 60);
		otherSeconds = otherSeconds % 60;
		newObject.setData(name, otherScore, otherMinutes, otherSeconds);
	}
	return newObject; //returns to total
}

int main()
{
	//declares all six objects
	RacingData car1, car2, car3, car4, car5, car6;
	//declare two totals and winner objects
	RacingData danikaTotalData, jeffTotalData, winner;
	//sets values
	car1.setData("Danika Patrick", 185, 11, 20);
	car2.setData("Danika Patrick", 103, 11, 30);
	car3.setData("Danika Patrick", 73, 12, 40);
	car4.setData("Jeff Gordon", 155, 10, 10);
	car5.setData("Jeff Gordon", 127, 11, 15);
	car6.setData("Jeff Gordon", 34, 12, 35);
	// add the total data
	danikaTotalData = car1 + car2 + car3;
	jeffTotalData = car4 + car5 + car6;
	
	//display winners accordingly 
	cout << "The performer with the highest score was: "; danikaTotalData.printData();
	cout << "The performer with the lowest time was: "; jeffTotalData.printData();
	winner;
	return 0;

	
}

That sounds like your homework. Does someone have a link to a post to not ask for homework here?

commented: read the Rues. Homework is perfectly allowable. -3

Regardless what it is, I'm asking for suggestions. Obviously your just trolling for no reason. So if you any suggestions on what you would have done differently that would be something helpful. If not, Find the exit now.

"Don't give away code!

You might feel inclined to help someone else. That's great! But don't solve the problem for them. Our goal is to help people to learn, and giving away answers doesn't achieve that goal. Naturally giving away the answer is a subjective thing, so just make sure that the person you help can't just take your code and turn it in for a grade. We want the people we help to do enough work to learn something meaningful."

According to that and what I stated above, suggestions would be helpful.

Things I want to avoid:
Operator/ function...

also I've tried dividing the class obj by 3, silly enough it wouldn't work as it obviously makes sense. You can't divide it like that but what I'm looking for is the other way to do what I'm required to do without having to create a "operator/".

Sorry, I thought you were asking to do the code for you. Don't you have to find who got less and who got more time with a program and not just print it. You can write a function to get a total time of each one, something like this:

int getTotalTime(int minutes, int seconds) {
	    int totaltime = seconds + (minutes * 60);
	    return totaltime;

and see who got less and who got more and then print out the one with correct time first.

Are u allowed to set a de-reference pointer to the value of danikaTotalData and divide that by 3??

Didn't see that one. Then just change the variables passed to member functions to &'s.

Those are some good examples and suggestions, I'll see what I can do.

"Are u allowed to set a de-reference pointer to the value of danikaTotalData and divide that by 3??"

Would that work?

I don't think so. It should go out of scope unless you pass the adress of the variables to the functions instead of their values.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.