The lowest discount on Harry Potter book purchase

Source: Internet
Author: User

· Bookstore for the "Harry Potter" series of books for promotional activities, a total of 5 volumes, with numbers 0, 1, 2, 3, 4, a single volume of 8 yuan, the specific discount is as follows:

Discount on this number

2 5%

3 10%

4 20%

5 25%

· Depending on the number of volumes purchased and this number, different discount rules will be applicable. The singular book only corresponds to one discount rule, for example, two volume 1, one volume 2, you can enjoy 5% discount, another volume does not enjoy the discount. · The design algorithm calculates the lowest price for the reader to buy a batch of books. Design ideas:  the first 5 book discount is definitely the lowest discount for all purchases. And then from the 6th to the 9th. Sixth book: 5 plus 1Seventh book: 5 plus 2Eighth book: 4 plus 4nineth Book: 5 plus 4so just divide the book you need to buy by dividing it by 5, and then compare the remainder with 5 and the few, the most special natural is 8, and then in the calculation. Code implementation: implementation: Personal Summary:

The lowest discount on Harry Potter book purchase

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.