hello i am having some trouble as i have left my notes at college and i am currently on half term
My program is to work out expenses for employees, so ihave used a for loop to loop he set of code that requires employees to input their data and the code for calculation, that seems to work fine
but what i need to do next is to calculate a department total so, how do i add all the expenses from the loop so that i output a department total
Code://for loop for the employees expnses statement for (i = 0; i <noemp; i++) { //clears screen after department details have been entered system("cls"); //Input for employees details //call function empdetails empdetails() ; //if the engine option is A if (esize == 'A'|| esize == 'a') { //if they have travelled less than 500 miles if (mtravel <= 500) { //call function under under(); tc = tr * 1; } //if they travelled over 500 miles else if (mtravel > 500) { //call function over over(); tc = toc * 1; } } //if the engine option is B else if (esize == 'B'|| esize == 'b') { //if they have travelled less than 500 miles if (mtravel <= 500) { //call function under under(); tc = tr * 0.8 } //if they travelled over 500 miles else if (mtravel > 500) { //call function over over(); tc = toc * 0.8; } } //if the engine option is C else if (esize == 'C'|| esize == 'c') { //if they have travelled less than 500 miles if (mtravel <= 500) { //call function under under(); tc = tr * 0.5; } //if they travelled over 500 miles else if (mtravel > 500) { //call function over over(); tc = toc * 0.5; } } //error message is correct character is not inputted else { //clears the screen before error message is shown system("cls"); cout << "ERROR - Please input A/B/C" <<endl <<endl; } //clears screen before expenses statement appears system("cls"); //Output of the expenses statement for employees //call function expenses expenses(); //calculation for total department expenses deptotal = tc + ; system("pause"); } //clear screen before department summary output system("cls"); //calculation for average expenses //Department summary output cout << deptotal; system("pause");
so i basically need to add all the tc variables together so that i get a total