//nf(variable ,left digit , right digit) void setup(){ loan(5000,0.12,1); //5000baht 12percent 1year } void loan(float amt,float rate,int yr){ int month=yr*12; float ratepm=rate/12; // rate per month per year float ppm=amt * ( ratepm / (1 - pow(1 + ratepm,-month))); //pay per month (pri+interest) float pri=ppm; // principal float unpaid=amt; // unpaid float total_interest=0; int i=1; println("No. Interest Principal Unpaid total interest"); while (i<=month){ print(nf(i,2));//NO. print(" "+nf(ratepm*unpaid, 2,2));//interest total_interest+=ratepm*unpaid; pri=ppm-(ratepm*unpaid); unpaid-=pri; if (unpaid<0)unpaid=0; print(" "+nf(pri,3,2)); // principal print(" "+nf(unpaid,4,2)); // unpaid print(" "+nf(total_interest ,3,2)); //total_interest println(); i++; } }
วันพุธที่ 9 กันยายน พ.ศ. 2558
Lab04 : Loan
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
commit เพิ่มเติม : เพื่ม userstory, bookmark
>> add userstory ทำการเพิ่ม userstory ใน functional tests >> add bookmark for user เพิ่มระบบ Bookmark โดยการสร้าง model ขึ...
-
1 2 3 4 5 6 7 8 9 def setup (): print (d2b( 8 )) def d2b (num): x = "" while num > 0 : x = str ( int (n...
-
1 2 3 4 5 6 7 8 9 10 11 12 13 def test_layout_and_styling ( self ): # Edith goes to the home page self . brow...
-
การใช้ template inheritence คือการสืบทอดเทมเพลต เพื่อให้ไม่ต้องเขียนโค้ดหน้าเว็บๆซ้ำๆ เราจะมีหน้าหลักอันเดียว (base.html or parent) ภายในนั...
ไม่มีความคิดเห็น:
แสดงความคิดเห็น