Consider the following situation you are to write a program


Scenario

Consider the following situation. Your local grocery store ran a contest where the contest winner was allowed to fill his/her car with however many groceries the winner could take home, at no cost to the contest winner.

And as a result, you were the lucky winner of that contest.

Requirements The included file groceries.txt contains a list of groceries available for you to take home in your car. The format of the file is the following broken across every three lines:

• Item Name (string)

• Item Weight in pounds (double)

• Item Cost in USD (double)

You are to write a program which loads the data into your program. There are a number of conditions to be aware of though:

Weight Restrictions Unfortunately your car is rather small and you are unable to drive off with every item in the store. You are only able to fit 100 pounds of groceries in your car.

Cost Optimization Since you are restricted with being only able to drive off with 100 pounds of groceries, you being the savvy shopper decided that you want to make the trip as worthwhile as possible and drive off with the most valuable items in the store.

You have devised the following algorithm (pseudocode) to help you obtain this goal: while weight limit is not hit select most valuable item from grocery store if weight of item is less than weight remaining in car add it to your car end if end while The weight of all items in your car cannot exceed 100 pounds when the algorithm completes.

Also you can only accept one of each item in the store (found in the groceries.txt file.) One last restriction, you can not take "partials" of items (either the whole item can be taken or it cannot fit in your car.) Instructions For this assignment, you are to write a C++ program implements the above algorithm. Your code is to read in the groceries.txt file and after processing you are to output the following:

• The name and cost of each item

• The total cost of all items in your car

• The total weight of all items in your car Please implement your solution based on the above requirements.

You can use any techniques you would like in your code (arrays, structures, vectors, et al.)

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Consider the following situation you are to write a program
Reference No:- TGS02919150

Expected delivery within 24 Hours