Problem:
Christmas is near, and Goostavo is preparing to buy Chriastmas presents!
He has one problem though, and you will have to help him with that.
Goostavo still doesn't know for how many people is he going to buy
presents. He also doesn't know his budget, and how big bag he is going to
carry for the presents. Actually, Goostavo doesn't know anything at all,
right now.
When Goostavo finds out all of those three things, he will have to go and
buy the presents. He must buy equal amount of presents for each person,
otherwise someone may get offended! He also wants to spend as much
money from the bugest, as possible!
You will have to write a function, that will calculate the maximum amount
of money he is going to spend from his budget.
Here is what you will be given:
1) The amount of money Goostavo has for spending.
2) The volume of the bag, in which he will carry the presents.
3) The number of people he has to buy presents for.
4) The number of presents in the store.
5) Volume and price for each present.
The function will look like that:
public static float Contest7(float budget, float bagVolume, int people, int
Npresents, float [] presentVolume, float [] presentPrice);
Example input:
budget = 183.23
bagVolume = 64.11
people = 7
Npresents = 12
presentVolume[0] = 4.53
presentPrice[0] = 12.23
presentVolume[1] = 9.11
presentPrice[1] = 45.03
presentVolume[2] = 4.53
presentPrice[2] = 12.23
presentVolume[3] = 6.00
presentPrice[3] = 32.93
presentVolume[4] = 1.04
presentPrice[4] = 6.99
presentVolume[5] = 0.87
presentPrice[5] = 0.46
presentVolume[6] = 2.57
presentPrice[6] = 7.34
presentVolume[7] = 19.45
presentPrice[7] = 65.98
presentVolume[8] = 65.59
presentPrice[8] = 152.13
presentVolume[9] = 14.14
presentPrice[9] = 7.23
presentVolume[10] = 16.66
presentPrice[10] = 10.00
presentVolume[11] = 13.53
presentPrice[11] = 25.25
Note
1) There can be two or more presents with equal price and volume!
2) The amount of presents in the store will always be greater to the
amount of people Goostavo has to buy presents for.
3) Remember: Goostavo can buy more than one present for each person,
but the amount of presents he gives to each person must be equal! i.e.
everyone gets 1 present, or everyone gets 2 presents, and so on...
4) Remember: Goostavo need to spend AS MUCH money as possible, but
not go over the budget!
Please i need the answer for this problem using c#.?
e=mc squared
Reply:I think you need to do your own homework.
Reply:Have him become a Jehovah's Witness... they don't celebrate christmas and he won't have to worry about buying any gifts.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment