Skip to content

Instantly share code, notes, and snippets.

@misostack
Last active February 20, 2023 14:27
Show Gist options
  • Save misostack/65c3a89df895033211b55b714cf6c6c9 to your computer and use it in GitHub Desktop.
Save misostack/65c3a89df895033211b55b714cf6c6c9 to your computer and use it in GitHub Desktop.
Algorithm

Algorithm

We're going to build an Office For Rent Application. Our Customer

  • They will sign with us at least one year contract
  • They have to pay 1 month rent deposit when they sign the contract
  • Their bill will be sent at the end of the current quarter ( 3, 6, 9, 12 )
  • They have to pay the rental fee in the 1st week of the new quarter ( 1, 4, 7, 10 )

001 : Rental fee

The total fee will be calculated for each month. Here is our fee calculation formula

  1. Full month : if they rent the entire month, they must pay 100% fee
  2. Partial month : if the month start from 1st and ended 30th and their contract ended in 21st of this month they only have to pay for 21 days

Inputs:

  • Start Date Contract
  • End Date Contract
  • Monthly Fee

Output:

  • Calculate the total fee of this contract
  • Report for monthly fee for the whole contract
ID Month StartDate EndDate Days Fee
1 01/22 15/01/2022 31/01/2022 16 16 * X
2 02/22 01/02/2022 28/02/2022 28 100%
3 03/22 01/01/2022 31/01/2022 31 100%
...
13 01/23 15/01/2023 31/01/2023 16 16 * X
@misostack
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment