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, 23.06.2019 05:00
Which best explains why a digital leader would join a society specializing in technology
Answers: 1
question
Computers and Technology, 24.06.2019 11:00
Which of the statements below describe the guidelines for the use of text in presentation programs? a. do not use numbered lists. b. fonts should be appropriate for your audience. c. limit the number of fonts you use to three or four. d. only use bulleted lists for sales promotions. e. select font sizes that are appropriate for your delivery method. f. use font colors that work well with your background. select all that apply
Answers: 1
question
Computers and Technology, 24.06.2019 15:30
If you want to delete an entire word at a time, which key should you press along with the backspace or delete key?
Answers: 1
question
Computers and Technology, 24.06.2019 17:50
You will subnet the network address 172.31.103.0/24. the network has the following requirements: · room-114 lan will require 27 host ip addresses · room-279 lan will require 25 host ip addresses · room-312 lan will require 14 host ip addresses · room-407 lan will require 8 host ip addresses how many subnets are needed in the network topology?
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
question
English, 20.04.2021 04:30
question
Biology, 20.04.2021 04:30