by Robert Sample » Mon Apr 16, 2018 3:15 am
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.
- These users thanked the author Robert Sample for the post:
- erich (Mon Apr 16, 2018 6:25 am)