Question: I DID ADD A FILE NAME COSTFILE IN THE FOLDER THAT CONTAINS .CPP FILE. PLEASE HELP ME. I DONT KNOW WHY I'M RECIVIN THIS ERROR.
I DID ADD A FILE NAME COSTFILE IN THE FOLDER THAT CONTAINS .CPP FILE. PLEASE HELP ME. I DONT KNOW WHY I'M RECIVIN THIS ERROR.
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

? unit 12- Microsuft Visual Studio File Edit View Project Build Debug Team Tools TestAnalyze Window Help Quick Launch (Ctrl dharmik patel unit_12.cpp* X Solution Explorer unit-12 (Global Scope) #include ?iostream rch Solution(xplorer (Ctrl+1 ?, #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
