1 Basketball Match
FAST University is organizing a basketball match for its students. This match will be
attended by a lot of families, the organizing team consisting of Bashir and Ali. They
have decided to buy chocolates and sell them to the kids present there. Various types of
chocolates can be bought at different range of prices.
However, some constraints have been applied on Bashir and Ali while they go buy
- The first constraint is to spend all their money in buying chocolates so no change
- The second constraint on them is that each one of them has to buy the same
chocolate. This will ensure that both Ali and Bashir will pay the same price for 1
- The last of these constraints is that both have to buy the chocolate with the
So for example, if the university gives $12 to Ali and $30 to Bashir, they will have to buy
the same type of chocolate, in this case it can be a chocolate which has a cost of $6.
Hence Ali will end up buying two chocolates from his $12 and Bashir will end up buying
five chocolates from his $30.
After buying their chocolates and coming back to the match, one of the guys who has
more chocolates takes the less populated area of the court to sell chocolates and the
other person with less chocolates takes the more populated area. The person who has
less chocolates will sell each piece at double the price he bought it for (the price you
calculated in part 1) and the person with more chocolates will sell each piece at the
price he bought it for initially and multiplied with a factor of 3/2 .
CS118 Programming Fundamentals (Fall 2020 - Semester Project)
Page 1 of 21.1 Tasks to do
There are two main tasks to complete:
- You have to implement this scenario using a function named “chocolatePrice()”,
which takes two input parameters i.e ali_budget and bashir_budget that returns
the price of a single chocolate Bashir and Ali will decide to buy.
- Your job now, is to write the code which calculates the profit Ali and Bashir will
make separately by selling all of their chocolates. You need to write the program
named “calculateProfit()”, which takes two input parameters i.e ali_budget and
bashir_budget. It will calculate the profit that Bashir and Ali made and then return
the maximum profit among the two.
a. If the input parameters are float you have to round it, else everything is
Note: Built-in and library functions are not allowed.