0

I have this project that takes a team name, how many members are on a team and the individual times. I need to output the teamname and times (in seconds) and then the total time of each team. I'm having trouble adding the total team times.

while(infile.peek() !=EOF)
{
	 getline (infile, teamName);
	 infile >> numRunners;

	 cout << teamName << endl;
	 cout << numRunners << endl;

	 for (i=1; i<=numRunners; i++)
	 {
		 infile >> runMinutes >> runSeconds; 
		 runTotal = (runMinutes * 60) + runSeconds; 
		
	  cout << runTotal << endl; //for testing purposes, outputs run times
	  
	 infile.ignore(1);

Edited by Narue: Fixed code tags

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by Narue
0

It would probably be easier if you stored the times entirely as seconds and then converted to "<minutes>:<seconds>" for display purposes. I don't suspect that these times are likely to exceed the limits of one of the integer or floating-point types.

Edited by Narue: n/a

0

I thought that I was doing that with line 12:

runTotal = (runMinutes * 60) + runSeconds;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.