Question: Create a function named CalcCost , which takes a string input filename and string output filename as a parameters. This function returns the number of

Create a function named CalcCost, which takes a string input filename and string output filename as a parameters. This function returns the number of entries read from the file. If the input file cannot be opened, return -1 and do not print anything to the output file.

Read each line from the given filename, parse the data, process the data, and print the required information to the output file.

Each line of the file contains PRODUCT NAME, COST PER ITEM, QUANTITY. Read and parse the data, then output the total cost for each entry.

If given the data below:

Seattle Coffee, 12.54, 39 Denver Mints, 1.00, 1877 Computer, 699.95, 16 

Your output file should contain:

Seattle Coffee: 489.06 Denver Mints: 1877.00 Computer: 11199.20 

You only need to write the function code. Our code will create and test your class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!