Question
Design and Implement a C++ Application. This assignment gives you an opportunity to learn about files, arrays, and pointers. A cost involves a Description, and
Design and Implement a C++ Application.
This assignment gives you an opportunity to learn about files, arrays, and pointers. A cost involves a Description, and an amount and An Item Number.
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.
Try this with some sample data, such as the following lines in costfile.dat You may add or create your own data file to test the program with: You can start with the data in a text file and then write the data in a binary file, this way you practice with both file types.
Description Amount Item number Pass_Go 200.00 135 Reading_RR 50.00 136 Connecticut 120.00 137 Chance 25.00 138
In order to get the full point for the assignment, make sure you follow the coding guidelines provided: - Use input file to read the above Data - Use header file for the data structure definition - Use Multiple Source Files for function definitions and Application, each in separate file (.cpp file)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started