[Solved] : Question 12629

Write a program that opens a file, reads records into a container of data structures, and prints out the sum in order.
You can use Vectors to contain the data structures.
1. Create a data structure to represent the record (struct cost in cost.h)
2. Write a function called parse_account that parses one (string) record from a file, and populates a data structure with that data.
3. Write a function called sum_accounts that, when passed a container of structures, returns a double representing the sum of the amounts in those structures.
4. Create a main program
a) Create an appropriate container of data structures
b) Open the accounts file (costfile.txt)
c) While you can read a line from the file without error
• Call parse_account, which returns a data structure.
• Add the returned data structure to the container (using, pushToV)
d) Call sum_accounts to determine the amount of money represented
e) Print a message and the result.
Pass_Go 200.0 135
Reading_RR -50.0 136
Connecticut -120.0 137
Chance 25.0 138


Expert Answer


Answer to : Question 12629

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?