Hello, I'm writing a program for my c++ class that requires me to read data from a file and the profits from each sales person. At the end i need to figure out the the total profits of all salespeople. However since i used a loop to process the data, I am a bit confused about how to calculate the total profits. I shall post my source code and the data file that goes along with it. Thanks to whoever decides to help.
void accumulate(void)
{
totalNet = netProfit;
cout << "\nThe total net profit is: $" << totalNet << endl;
return;
}
(can't find an attach,ents button so here is the data)
Hickle 2245.78 1072.49
Persells 11710.14 9735.38
Tipay 4567.51 3119.22
Zuller 5793.59 4204.45
stop
You're calling accumulate once in your main line. Also, accumulate isn't accumulating anything.
You want to initialize totalNet to zero. Then EACH time you canculate netProfit, you want to add it to totalNet. Then when you're done, you can print totalNet.
PLEASE USE CODE TAGS (the <> formatting button) when posting code. It makes it easier to read your code, makes it easier to respond to your question, and improves the chances of getting a response.