1. Homepage
  2. Homework
  3. CS1315 Computer Programming Assignment One - Cheapest Payment
This question has been solved

CS1315 Computer Programming Assignment One - Cheapest Payment

Engage in a Conversation
CityU Hong KongCS1315Computer ProgrammingC++

CS1315 Computer Programming Assignment One (2024-25 Sem. A)
Deadline: 30-Oct-2024 13:00 (Week 9 Wed) No Late submission will be accepted CourseNana.COM

Problem description CourseNana.COM

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: CourseNana.COM

A) Buy-X-get-Y-free: CourseNana.COM

  •   X and Y are positive integers (>=1). CourseNana.COM

  •   Customer must pay X people in Adult price and up to 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). CourseNana.COM

  •   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 X Adult requirement, then the remaining 2 Children will enjoy the Y free quotas). CourseNana.COM

  •   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 X Adult requirement, so that the remaining 2 Children will be free). CourseNana.COM

    B) D-percent-offforZormore: CourseNana.COM

  •   Z is positive integer (>=1) and D is between 0 and 100 (inclusive). CourseNana.COM

  •   The 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. CourseNana.COM

  •   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%)) CourseNana.COM

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: CourseNana.COM

  •   Enjoy 40% off for all 3 of them, or, CourseNana.COM

  •   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) CourseNana.COM

  •   Of course, they could choose to pay for a non-existing Adult to enjoy buy-1-get-1 two times... CourseNana.COM

    However for a group of 2 Adults and 3 Children, they may choose to: CourseNana.COM

  •   Enjoy 40% off for all 5 of them, or, CourseNana.COM

  •   Enjoy buy-1-get-1 for 1 Adult and 1 Child; Enjoy 40% off for the remaining 1 Adult and 2 Children, or, CourseNana.COM

  •   Enjoy buy-1-get-1 for 2 Adults and 2 Children; paying the remaining Child normally. CourseNana.COM

  •   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. CourseNana.COM

    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). CourseNana.COM

    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. CourseNana.COM

Sample Input / Output: CourseNana.COM

Example 1: (User Input is underlined) CourseNana.COM

Example 2: (User Input is underlined) CourseNana.COM

Example 3: (User Input is underlined) CourseNana.COM

Example 4: (User Input is underlined) CourseNana.COM

Marking criteria CourseNana.COM

Submitted program will be tested repeatedly with PASS. Marks will be graded objectively CourseNana.COM

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). CourseNana.COM

If the program is not compilable in PASS, zero mark will be given. CourseNana.COM

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 re-mark program output. CourseNana.COM

Input the Price for Adult: 250
Input the Price for Child/Senior: 150
Input the counts of Adult and Child: 2 3
Input X Y for the Buy-X-get-Y: 1 1
Input D Z for group discount: 40 3
The payment is: $570.000
Input the Price for Adult: 250
Input the Price for Child/Senior: 150
Input the counts of Adult and Child: 2 3
Input X Y for the Buy-X-get-Y: 1 1
Input D Z for group discount: 30 3
The payment is: $635.000
Input the Price for Adult: 250
Input the Price for Child/Senior: 150
Input the counts of Adult and Child: 2 3
Input X Y for the Buy-X-get-Y: 1 1
Input D Z for group discount: 10 3
The payment is: $650.000
Input the Price for Adult: 499.9
Input the Price for Child/Senior: 299.9
Input the counts of Adult and Child: 2 3
Input X Y for the Buy-X-get-Y: 3 2
Input D Z for group discount: 33.33333 3
The payment is: $1266.333

CourseNana.COM

Unlike tutorial exercises, for assignment, PASS will NOT make ALL test cases visible. (i.e. there are hidden test cases). Queries regarding hidden test case(s) will NOT be answered. It is the responsibility of a programmer to design own test cases in order to verify the correctness of the written program. CourseNana.COM

Note that the marking in PASS is automatic, therefore the following situations may lead to zero marks: CourseNana.COM

Input/output does not match the requirements as defined.
(e.g. incorrect spacing, incorrect spelling, letter cases or punctuations) CourseNana.COM

Submission of non .cpp files (e.g. .exe or .zip files)
Not uploading via “Submit” function. (Note: Upload via “Test” button will NOT be counted) CourseNana.COM

(Students may test or submit many times, only the last “submit” will be marked) CourseNana.COM

Please also note that the PASS plagiarism check will also be turned on. The same disciplinary action will be applied without distinguishing which one is the source / copier. Please safeguard your files if you work on your assignment using public computers (e.g. CityU Lab) CourseNana.COM

Testing and Submission CourseNana.COM

Students should submit cpp file to PASS before the deadline. All other submission methods (e.g. hardcopy, email...etc) will be ignored. Students may use whatever IDE/compiler for development, but program which is not compilable in PASS will lead to zero mark (e.g. program using non-standard, platform-specific features). The marker will make no attempt to fix the syntax error or make the code compilable. CourseNana.COM

If you observe that the answer in PASS is different from the one you get in your PC, most likely it is caused by programming bugs like uninitialized variables. The result by PASS will be used for marking without consideration of what you observed in your local PC. CourseNana.COM

Please also note that the PASS system could be extremely busy and may become sluggish in responding near deadline. You’re suggested to reserve enough time for submission (Not the usual button, but the Submit” button for assignments). CourseNana.COM

To protect yourself, it is advised that you write down your particulars (full name, student number, eid...) in the beginning of your source code as comment CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
CityU Hong Kong代写,CS1315代写,Computer Programming代写,C++代写,CityU Hong Kong代编,CS1315代编,Computer Programming代编,C++代编,CityU Hong Kong代考,CS1315代考,Computer Programming代考,C++代考,CityU Hong Konghelp,CS1315help,Computer Programminghelp,C++help,CityU Hong Kong作业代写,CS1315作业代写,Computer Programming作业代写,C++作业代写,CityU Hong Kong编程代写,CS1315编程代写,Computer Programming编程代写,C++编程代写,CityU Hong Kongprogramming help,CS1315programming help,Computer Programmingprogramming help,C++programming help,CityU Hong Kongassignment help,CS1315assignment help,Computer Programmingassignment help,C++assignment help,CityU Hong Kongsolution,CS1315solution,Computer Programmingsolution,C++solution,