編寫 C 程式以計算分期付款餘額
問題
編寫一個 C 程式來計算每月需要支付的餘額分期付款,用於特定貸款金額(含利息)。
解決方案
以下是給定貸款金額的利息計算公式 −
i=loanamt * ((interest/100)/12);
以下計算結果含利息金額 −
i=i+loanamt; firstmon=i-monthlypayment; //first month payment with interest i=firstmon * ((interest/100)/12);
程式
#include<stdio.h>
int main(){
float loanamt,interest,monthlypayment;
float i,firstmon,secondmon;
printf("enter the loan amount:");
scanf("%f",&loanamt);
printf("interest rate:");
scanf("%f",&interest);
printf("monthly payment:");
scanf("%f",&monthlypayment);
//interest calculation//
i=loanamt * ((interest/100)/12);
//amount with interest
i=i+loanamt;
firstmon=i-monthlypayment; //first month payment with interest
i=firstmon * ((interest/100)/12);
i=i+firstmon;
secondmon=i-monthlypayment; //second month payment with interest
printf("remaining amount need to pay after 1st installment:%.2f
",firstmon);
printf("remaining amount need to pay after 2nd installment:%.2f
",secondmon);
return 0;
}輸出
enter the loan amount:45000 interest rate:7 monthly payment:1000 remaining amount need to pay after 1st installment:44262.50 remaining amount need to pay after 2nd installment:43520.70
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP