Page 1 of 1

Need some help with arrays.

PostPosted: Mon Apr 16, 2018 2:56 am
by erich
Hello,

I am struggling to understand the array situation in this program. I've listed the file definition in the picture. Any help would be appreciated.

Re: Need some help with arrays.

PostPosted: Mon Apr 16, 2018 3:15 am
by Robert Sample
You need an array with 4 occurrences -- 1 for each booking type. For each booking type, you need to have a trip total cost variable, and you need a trip count variable. Initialize the trip total cost and trip count to zero for each array element. Then your processing will be to read a record, add the trip cost to the total cost for that booking type, add 1 to the trip count for that booking type, and repeat until end of file. When you hit end of file, calculate the average trip cost for each booking type and print.