I really love working with structs, and I get how they work and everything. And I know my issue right now is the math (I'm horrible at math!) But my problem: I need to create a program that reads from a .txt file of employees (let's say 5) an they're quarterly sales. (check, got that working). I need the cout to display the last name and sales of each (check) and then add up the quarterly sales totals (check). Then, this is where I get stuck, is I gotta find the highest and lowest total quarterly sales & assign a bonus to the highest, nothing to the lowest, and a bonus to everyone else.
So far, I have
quarterSales.quarterOne + quarterSales.quarterTwo + quarterSales.quarterThree + quarterSales.quarterFour
for the total of the sales. Then I was starting a for loop to determine the highest and lowest.
for (int x = 0; x < 5; x++)
{
if (quarterSales[x] > highest)
highest = quarterSales[x]
}
Then the same goes for the lowest (changing the operator in the if statement accordingly). I guess I don't know how to go about incorporating the struct. If the total quarterly sales is something that is calculated from the information in the .txt file and not something directly from the file, how would I even declare a quarterlySales.totalSales variable?
Because I keep thinking that I need to do
quarterlySales.totalSales = quarterlySales.totalSales + highBonus
quarterlySales.totalSales = quarterlySales.totalSales + regularBonus
or something like that, since I know that's not right.
Am I close in my thought process? I feel like I'm incredibly wrong.