Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

[Solved]Percentages

Discussion in 'Scripting' started by Captain_Zip, Feb 4, 2018.

  1. Captain_Zip

    Captain_Zip

    Joined:
    Feb 4, 2018
    Posts:
    6
    If someone requested a loan, and then payed 3.5% of it each month, how would it work? Also adding a max value for how much they can barrow?
    Code (CSharp):
    1. //Assuming they're using the InputCanvas
    2.  
    3. void Loan(int amountMoney)
    4. {
    5. currentMoney = currentMoney + amountMoney;
    6.  
    7. }
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Hmm.? :)

    Well, how would you subtract 3.5% of an amount of money? Feels like the answer is in the question :)
    Perhaps track the borrowed amount, and always take 3.5% of that value per month.

    As for a max value, again it feels like the answer is in the question.
    Check that the value is <= the max value.
     
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    For reference, that would be
    Code (CSharp):
    1. repayment = amountOfLoan * repaymentRate / 100;
     
  4. Captain_Zip

    Captain_Zip

    Joined:
    Feb 4, 2018
    Posts:
    6
    Worked Thanks, I figured it out then you replied with similar answer lmao