Not exactly sure how to ask for help on this program. I've read in data from a file and displayed it to the screen as required. Made the calculations and now I'm supposed to write the data for "Trip Number" and "final cost" to 2-parallel arrays. But here is the kicker...I'm supposed to write it in reverse order. The output file has some crazy numbers in it. Can someone please help or point me in the right direction? Thank you..
constint ARRAY_SIZE = 200; //array size of 100 elements
Here either the comment lies, or the declaration is wrong. Decide.
1 2 3 4
for(counter = 0; counter < ARRAY_SIZE; counter++) //use for loop to output to file
{
fileSave << nbrOfTrips[counter]<<totalCost[counter]<<endl;
}
This doesn't iterate the contents of the arrays in reverse, and you also do not put a whitespace between what you output so that may be why you're getting "crazy numbers".
My mistake...yes the array size will be up to 100. At least the instructions said "Assume the company has up to 100 trips." I should have given better instructions what the output would be as well. The input file looked like this.
50 //for trip number
50.00 //cost of gas
125.00 //cost of waste
250.00 //misc costs
75 //next trip number etc...etc..with the cost.
Now that I've read in the data, made the calculation to discount the fuel and output to screen I'm supposed to output to the file the:
trip number and final cost in reverse order so it would look something like this:
75 //trip number
550.00 //final cost
50 //trip number
450.00 //final cost of that trip.
I'm pretty lost on this exercise. Why can't professors take it slower and teach us the complex material? 7-days to do these, work and other classes is ridiculous. Everyone has to work now and school is not the same. Any help is greatly appreciated.