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, 21.06.2019 23:00
Explain briefly why you cannot expect to find a previous version of every file with which you work.
Answers: 1
question
Computers and Technology, 22.06.2019 14:00
Which database model is best used for data warehouse and data mining
Answers: 3
question
Computers and Technology, 22.06.2019 18:00
Write a method named addall that could be placed inside the hashintset class. this method accepts another hashintset as a parameter and adds all elements from that set into the current set, if they are not already present. for example, if a set s1 contains [1, 2, 3] and another set s2 contains [1, 7, 3, 9], the call of s1.addall(s2); would change s1 to store [1, 2, 3, 7, 9] in some order. you are allowed to call methods on your set and/or the other set. do not modify the set passed in. this method should run in o(n) time where n is the number of elements in the parameter set passed in.
Answers: 2
question
Computers and Technology, 23.06.2019 06:30
You have a small company and want to keep your costs low, but it is important your employees share data. which network would provide you with the most economical solution?
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
Questions on the website: 13722362