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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:00
Search the web for two examples of digital art that you like. the examples must be from different mediums (example: one digital photo and one computer animation not two computer animations). compose an essay for each example you choose about why the piece appeals to you, and identify the medium used.
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Plz ( which is an example of a good url?
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
What are loans to a company or government for a set amount of time
Answers: 1
question
Computers and Technology, 24.06.2019 14:30
Ahousehold consists of a married couple and their twin five-year old daughters. the couples children had no income and lived with their parents all of last year. how many exemptions can the couple claim on last years tax return or they file with the “ married filing jointly “ status? a. 4 b. 5 c. 3 d. 2
Answers: 1
You know the right answer?
Program 1 - Gift Card Utilization:

You got a gift card for your local store. It has som...
Questions
question
Biology, 30.11.2020 21:40
question
Chemistry, 30.11.2020 21:40
Questions on the website: 13722360