Question: in C + + . The problem is tricky because we can also use x - y discount for 2 , then d - z
in C The problem is tricky because we can also use xy discount for then dz discount for remaining ppl See test case
Consider a buffet restaurant with two price settings: Adult eg$ and Child Senior eg$ You may assume that both prices are nonnegative 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 BuyXgetYfree:
quad mathbfX and mathbfY are positive integers
quad Customer must pay mathbfX people in Adult price and up to mathbfY Children Seniors will be free. less than Y is okay. eg A group of Adults and Child can also make use of buyget so Adults will pay and Child will be free
Child Senior may also pay in Adult price if needed.
eg Suppose the discount is buyget For a bill with Adult and Children, one of the Children could pay in Adult price to fulfill the boldsymbolX Adult requirement, then the remaining Children will enjoy the boldsymbolY free quotas
Creating "ghost" customer is also okay.
eg Suppose the discount is buyget For a bill with Adult and Children, the customers could choose to pay for a nonexisting adult to fulfill the boldsymbolX Adult requirement, so that the remaining Children will be free
B Dpercentoff for mathbfZ or more:
quad mathbfZ is positive integer and mathbfD is between and inclusive
quad The mathbfZor more customers could be of mixed AdultChild types and the D percent off will be applied to the original bill for them.
Creating "ghost" customer is also okay.
eg Suppose the discount is off for A table of Adults and Child could choose to pay for a nonexisting child, so that the bill will be Adults Children
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 buyget as well as offfor A group of Adult
and Children may choose to:
Enjoy off for all of them, or
Enjoy buyget for Adult and Child; paying the remaining Child normally.
ie Adult pays, Child is free and the "remaining Child" do not enjoy off, as
the number of "remaining" customer is not
Of course, they could choose to pay for a nonexisting Adult to enjoy buyget
two times...
However for a group of Adults and Children, they may choose to:
Enjoy off for all of them, or
Enjoy buyget for Adult and Child; Enjoy off for the remaining Adult
and Children, or
Enjoy buyget for Adults and Children; paying the remaining Child
normally.
Of course, if they like, they can also pay for a nonexisting Adult and enjoy
buyget 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 no checking is needed but the numbers are not necessarily realistic eg price
of $ buyget or 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 decimal places.
Sample Input Output:
Example : User Input is underlined
Input the Price for Adult:
Input the Price for ChildSenior:
Input the counts of Adult and Child:
Input X Y for the BuyXgetY:
Input D Z for group discount:
The payment is: $
Example : User Input is underlined
Input the Price for Adult:
Input the Price for ChildSenior:
Input the counts of Adult and Child:
Input X Y for the BuyXgetY:
Input D Z for group discount:
The payment is: $
Example : User Input is underlined
Input the Price for Adult:
Input the Price for ChildSenior:
Input the counts of Adult and Child:
Input X Y for the BuyXgetY:
Input D Z for group discount:
The payment is: $
Example : User Input is underlined
Input the Price for Adult:
Input the Price for ChildSenior:
Input the counts of Adult and Child:
Input X Y for the BuyXgetY:
Input D Z for group discount:
The payment is: $
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 NO manual attempt to check or remark program output.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
