subject

Program 1 - Gift Card Utilization:

You got a gift card for your local store. It has some credit you can use to buy things, but it may be used only for up to two items, and any credit you don't use is donated to charity. You want to maximize the amount of the card you spend. Therefore, you want to buy two items which add up as close to the gift card value as possible. You will generate the value of the gift card (random amount between $25 and $75) and a list of 10 item values (in increments of $5. from $5 to $50) in an array. You should return a pair of indices that correspond to values that add up to the gift card total or as close as possible. Hint #1: it is highly recommended that you print out the array to the screen for debugging; it can be included as part of the output. Something like:

| $14 | $25 / $ 71 $ 48 $171 $191 $331 $21$471 $10||

Hint #2: this can't be solved by doing only one pass of the array... How do you know if the first element is part of the solution? What about the second?

Sample Output (your gift card amount will differ):

Gift Card Amount: 64 You bought item #9 for $50 You bought item #1 for $10 Amount Donated to Charity: 4

Gift Card Amount: 71 You bought item #9 for $50 You bought item #3 for $20 Amount Donated to charity: 1

Gift Card Amount: 56 You bought item #9 for $50 You bought item #0 for $5 Amount Donated to charity: 1

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 08:30, Bradgarner772
Based on your knowledge of a good network, describe what you think is a perfect network would be. what kind of information and resources could users share on this network. what would the network administrator do? what kind of communication would be used?
Answers: 1
image
Computers and Technology, 23.06.2019 10:30, badpotterchris
How would you categorize the software that runs on mobile devices? break down these apps into at least three basic categories and give an example of each.
Answers: 1
image
Computers and Technology, 23.06.2019 23:00, minosmora01
How do you know if the website is secure if you make a purchase
Answers: 2
image
Computers and Technology, 24.06.2019 05:30, MOONCHILDSUGA
If you combine two cells into one, what action are you performing? a.  adding a new row or column      b.  splitting the cells      c.  removing a new row or column      d.  merging the cells
Answers: 2
You know the right answer?
Program 1 - Gift Card Utilization:

You got a gift card for your local store. It has som...

Questions in other subjects:

Konu
English, 21.11.2020 01:00
Konu
Mathematics, 21.11.2020 01:00
Konu
Mathematics, 21.11.2020 01:00