Running Total

I'm trying to figure out the running total, but I don't understand it.

(Sorry, this is for the same program that I still need to figure out how to put a 0 in front of the dates too)

setnum = 0;
num1 = 0;
num2 = 0;
numsame = 0;

while (fin)
{ setnum = 1 + setnum;
fout << setnum << "." << setw(5) << month1 << "/" << day1 << "/" << year1
<< setw(5) << month2 << "/" << day2 << "/" << year2;
if (year1 > year2 || year1 == year2 && month1 > month2 || year1 == year2 && month1 == month2 && day1 > day2)
{ num2 = true;
fout << setw(10) << "Second" << endl;
num2 = num2 + 1;
}
else if (year1 < year2 || year1 == year2 && month1 < month2 || year1 == year2 && month1 == month2 && day1 < day2)
{ num1 = true;
fout << setw(10) << "First" << endl;
num1 = num1 + 1;
}
else if (year1 == year2 && day1 == day2 && month1 == month2)
{ numsame = true;
fout << setw(10) << "Same" << endl;
numsame = numsame + 1;
}
fin >> month1 >> day1 >> year1 >> month2 >> day2 >> year2;
}

fout << "--------------------------------------" << endl << endl
<< "------------------------" << endl
<< setw(8) << "First" << setw(8) << "Second" << setw(8) << "Same" << endl
<< setw(8) << num1 << setw(8) << num2 << setw(8) << numsame << endl
<< "------------------------" << endl;

return 0;
}


Here's the output

--------------------------------------
# First Second Older?
--------------------------------------
1. 5/23/1979 2/16/1972 Second
2. 5/7/1955 3/2/1956 First
3. 8/16/1961 7/18/1961 Second
4. 2/20/1950 1/24/1950 Second
5. 5/31/1983 5/5/1983 Second
6. 4/16/1994 4/21/1994 First
7. 3/29/1945 3/29/1945 Same
8. 10/15/1956 10/13/1955 Second
9. 11/11/1919 12/11/1919 First
10. 1/2/2002 1/2/2002 Same
--------------------------------------

------------------------
First Second Same
2 2 2
------------------------

I guess I'm just trying to figure out how to code running totals?
Topic archived. No new replies allowed.