For the program I had to pull the information for the first 4 columns from a file called BusInput.txt with this in it.
111 100.00 200.00 50.00
222 200.00 300.00 100.00
333 400.00 500.00 75.00
The last 2 columns I calculated with a variable.
NOW, I need to find the sum of all of the columns EXCEPT the Bus No.
This is my current code. How do I get the sum of all of the columns?
You don't read anything into the array 'num'. Then you nevertheless sum up all the (undefined) values of the array to one variable: 'total'.
When you do: cout << "Totals " << total << endl;
you do print exactly one value.
You cannot have a 2D array of all the input values, because the first column is int and the rest are double.
You could have 1D array of struct type that has four members: busNum, fuel, equip, misc
I don't need the sum of the first column so maybe that is why the professor set it up that way?
I have actually already done the program with variables set up just like sFuel += fuel; so that I could finish the rest of it.
The array is part of the assignment or I would have just left it with the variables which work without issue. I found the code with the for loops online on several sites as well as in my book. I was unable to make it work that's when I turned to this forum.
I figured it must be an issue somewhere in my code preventing it.