Question: Problem description Consider a buffet restaurant with two price settings: Adult ( e . g . $ 2 0 0 ) and Child /

Problem description
Consider a buffet restaurant with two price settings: Adult (e.g.\$200) and Child / Senior (e.g.\$150). You may assume that both prices are non-negative (with the Adult price is always higher) and assume that there is no service charge. To attract more customers, the restaurant is offering two types of discounts:
A) Buy-X-get-Y-free:
-\(\quad \mathbf{X}\) and \(\mathbf{Y}\) are positive integers (\(>=1\)).
-\(\quad \) Customer must pay \(\mathbf{X}\) people in Adult price and up to \(\mathbf{Y}\) Children / Seniors will be free. (less than \( Y \) is okay. e.g. A group of 2 Adults and 1 Child can also make use of buy-2-get-2, so 2 Adults will pay and 1 Child will be free).
- Child / Senior may also pay in Adult price if needed.
(e.g. Suppose the discount is buy-2-get-2. For a bill with 1 Adult and 3 Children, one of the Children could pay in Adult price to fulfill the \(\boldsymbol{X}\) Adult requirement, then the remaining 2 Children will enjoy the \(\boldsymbol{Y}\) free quotas).
- Creating "ghost" customer is also okay.
(e.g. Suppose the discount is buy-2-get-2. For a bill with 1 Adult and 2 Children, the customers could choose to pay for a non-existing adult to fulfill the \(\boldsymbol{X}\) Adult requirement, so that the remaining 2 Children will be free).
B) D-percent-off for \(\mathbf{Z}\) or more:
-\(\quad \mathbf{Z}\) is positive integer (>=1) and \(\mathbf{D}\) is between 0 and 100(inclusive).
-\(\quad \) The \(\mathbf{Z}\)(or more) customers could be of mixed (Adult/Child) types and the D percent off will be applied to the original bill for them.
- Creating "ghost" customer is also okay.
(e.g. Suppose the discount is 50\% off for 4. A table of 2 Adults and 1 Child could choose to pay for a non-existing child, so that the bill will be (2 Adults +2 Children)*50\%)) The bill could be partitioned so that different customers in the bill could enjoy different discounts. However no single customer could enjoy both discounts. For instance, if the discounts are buy-1-get-1 as well as \(40\%\)-off-for-3. A group of 1 Adult and 2 Children may choose to:
- Enjoy \(40\%\) off for all 3 of them, or,
- Enjoy buy-1-get-1 for 1 Adult and 1 Child; paying the remaining Child normally. (i.e.1 Adult pays, 1 Child is free and the "remaining Child" do not enjoy 40\% off, as the number of "remaining" customer is 1, not 3)
- Of course, they could choose to pay for a non-existing Adult to enjoy buy-1-get-1 two times...
However for a group of 2 Adults and 3 Children, they may choose to:
- Enjoy \(40\%\) off for all 5 of them, or,
- Enjoy buy-1-get-1 for 1 Adult and 1 Child; Enjoy \(40\%\) off for the remaining 1 Adult and 2 Children, or,
- Enjoy buy-1-get-1 for 2 Adults and 2 Children; paying the remaining Child normally.
- Of course, if they like, they can also pay for a non-existing Adult and enjoy buy-1-get-1 for a total of three times in the bill.
Your task is to find out the cheapest payment amount given the corresponding prices, discount settings and headcounts. The numbers are always in the valid range stated in page 1(no checking is needed) but the numbers are not necessarily realistic (e.g. price of \$0, buy-1-get-4, or \(99\%\) off could be possible).
Your program should output exactly in the format (spelling, spacing...etc) as shown in the next page, with the final amount shown in 3 decimal places. Sample Input / Output:
Example 1: (User Input is underlined)
Input the Price for Adult: 250
Input the Price for Child/Senior: 150
Input the counts of Adult and Child: 23
Input X Y for the Buy-X-get-Y: \(1\frac{1}{3}\)
Input D Z for group discount: 403
The payment is: \(\$ 570.000\)
Example 2: (User Input is underlined)
Input the Price for Adult: \(\underline{250}\)
Input the Price for Child/Senior: 150
Input the counts of Adult and Child: \(\underline{23}\)
Input X Y for the Buy-X-get-Y: \(1\frac{1}{2}\)
Input D Z for group discount: 303
The payment is: \(\$ 635.000\)
Example 3: (User Input is underlined)
Input the Price for Adult: \(\underline{250}\)
Input the Price for Child/Senior: 150
Input the counts of Adult and Child: 23
Input X Y for the Buy-X-get-Y: \(1\frac{1}{10}\)
Input D Z for group discount: \(10\frac{1}{3}\)
The payment is: \(\$ 650.000\)
Example 4: (User Input is underlined)
Input the Price for Adult: 499.9
Input the Price for Child/Senior: 299.9
Input the counts of Adult and Child: 23
Input X Y for the Buy-X-get-Y: 32
Input D Z for group discount: 33.333333
The payment is: \(\$ 1266.333\)
Marking criteria
Submitted program will be tested repeatedly with PASS. Marks will be graded objectively based on the number of correct outputs reported by PASS (no matter whether it's the same as what you saw in your development platform or not).
- If the program is not compilable in PASS, zero mark will be given.
- Make sure that the output format (spelling, punctuations, spacing...etc) follows exactly the sample output above otherwise PASS will consider your answer incorrect. Marker will make
Problem description Consider a buffet restaurant

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!