วันพฤหัสบดีที่ 10 กันยายน พ.ศ. 2558

Loan money.

void setup(){
  loan_money(5000,0.12,1);
}
void loan_money(float amount, float rate, int year){
  int month = year*12;
  float ratepermonth = rate/12;
  float paypermonth = amount*(ratepermonth/(1-pow(1+ratepermonth,-month)));
  float principal = paypermonth;
  float unpaid = amount;
  float interest_total = 0;
  int x = 1;
  println("Num.  Interest  Principal  Unpaid  Interest total");
  while(x <= month){
    print(nf(x, 2)); //Num
    print("     "+nf(ratepermonth*unpaid, 2, 2)); //Interest
    interest_total+=ratepermonth*unpaid;
    principal=paypermonth-(ratepermonth*unpaid);
    unpaid -= principal;
    if(unpaid < 0){
      unpaid = 0;
    }
    print("     "+nf(principal, 3, 2)); //Principal
    print("    "+nf(unpaid, 4, 2)); //Unpaid
    print("     "+nf(interest_total, 3, 2)); //Total
    println();
    x++;
  }
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

Link Video Presentation Resort Managemant System Project.

Video Presentation Resort Managemant System Project. จัดทำโดย พากษ์เสียง: คุณาสิน  ทองมณี  5801012620011 ลำดับภาพ: สุพิชชา  ศรีศิริ...