Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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.)

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93113164

Have any Question?


Related Questions in Computer Engineering

Can someone please code this simple background subtraction

can someone please code this simple background subtraction but with height and width ratio to detect a human being. Please! I so badly need it for my dissertation,, cant make a loop that would subtract the every frame fr ...

Start from scratch on each of the parts write a main

Start from scratch on each of the parts. Write a main function that declares an array of 100 doubles. In a for loop, assign each of the doubles a random number between 0.50 and 50.00. Here's how. array[i] = (double) (ran ...

Be sure to show the equation and proportion from table you

Be sure to show the equation and proportion from table you used to calculate your answer 1) What is the upper arm weight for a 70 kg male? 2) What is the torso mass for a 65 kg female? 3) What is the weight of the right ...

Identify and evaluate at least three considerations that

Identify and evaluate at least three considerations that one must plan for when designing a database. Suggest at least two types of databases that would be useful for small businesses, two types for regional level organi ...

Research parallel computing and prepare an informal paper 2

Research parallel computing and prepare an informal paper 2 -3 pages in length, single spaced with a blank line beltween paragraphs. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

Give an example of a merger or acquisition where technology

Give an example of a merger or acquisition where technology contributed to its failure to produce desired outcomes. What reasons caused the failure? What actions might have helped ensure success?

What are impacts that flexible work schedules can have on a

What are impacts that flexible work schedules can have on a employee's productivity?

Question high-performing teambullimagine that you are an

Question: "High-Performing Team" • Imagine that you are an agile coach. Outline a plan that sets the expectations for your team when beginning a project. Provide a rationale for your response. • Read the mini-case titled ...

Suppose you have a data file exampledat with two columns

Suppose you have a data file example.dat with two columns that contain bivariate data. Let's call these two variables X and Y. Write a MATLAB script (accompanied by explanations) that will use the data from the file to d ...

Argue why wireshark should be outlawed and it is a clear

Argue why Wireshark should be outlawed and it is a clear violation of privacy act and then argue why it should not be out outlawed and that it is a vital resource to be freely used and does not violate the privacy act

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As