『壹』 c語言編程 從銀行貸款d,每月還款額為p,月利率為r,算多少月能還清。設d為300000,p為6000,r為1%.
#include <stdio.h>
#include <math.h>
int main()
{float d=300000,p=6000,r=0.01,m;
m=log10(p/(p-d*r))/log10(1+r);
printf("m=%6.2f\n",m);
return 0;
}
望採納,謝謝
『貳』 C語言程序題,在線等
如果log是以10為底的話,如下:如果是ln,就把下面log10改為log
#include<stdio.h>
#include<math.h>
int main()
{
int d=300000,p=6000;
double r=0.01;
double m=log10(p/(p-d*r))/(log10(1+r));
printf("還清月數:%.1f\n",m);
}
『叄』 有關銀行貸款還貸的c語言程序
你的錯誤實在太多了。看代碼王的程序簡潔易懂
#include<stdio.h>
#include<math.h>
int main()
{
double z,k,x,monthPay,allMoney,temp=0;
int n,i;
printf("輸入借款總額、貸款年限、年利率: ");
//貸款總和最好不要用int型的,int的最大值是32767,那你豈不是超了
scanf("%lf%d%lf",&z,&n,&k);
//計算n年後要還的總的錢數 pow(x,y)是在頭文件math.h中的函數計算x^y
allMoney = z*pow((1+k/12),12*n);
//式子∑x(1+k/12)^i (i=0,1,2,..,n*12-1)將x提出到前面計算 temp=∑(1+k/12)^i
for(i=0; i<12*n; i++)
temp += pow((1+k/12),i);
//根據等式z(1+k/12)^(12*n) = ∑x(1+k/12)^i (i=0,1,2,..,n*12-1) 得x=allMoney/temp;
x = allMoney/temp;
printf("每月應還款:%lf", x);
}
『肆』 C語言問題
本金加利息=本金*(1+月利率)^月數
在c里有一個乘方函數pow()
pow(a,b) 等於a的b次方
#include<stdio.h>
#include<math.h>
main()
{
doublemoney,capital;
doublerate[4]={0.009,0.01,0.0111,0.012};
intn;
printf("請輸入本金和期限(年) ");
scanf("%lf%d",&capital,&n);
if(n>3)
money=capital*pow((1+rate[3]),12*n);
else
money=capital*pow((1+rate[n-1]),12*n);
printf("%d年後本金和利息合計為:%.2lf ",n,money);
}
『伍』 C語言計算貸款問題 輸出不正確
printf("money(%lf,%d)=%lf\n",loan,year,money);
『陸』 C語言題:某客戶為購房辦理商業貸款,選擇了按月等額本息還款方式,計算公式如下。在貸款本金(loan
#include<stdio.h>
floatcal_power(floatx,intn)
{
floatp=1.0;
while(n>0){
p=p*x;
n--;
}
returnp;
}
floatcal_money(intloan,floatrate,intmonth)
{
doubletmp;
tmp=cal_power(1+rate,month);
returnloan*rate*tmp/(tmp-1);
}
intmain(void)
{
intloan,year,month;
floatmoney,rate;
printf("Enterloan:");
scanf("%d",&loan);
printf("Enterrate:");
scanf("%f",&rate);
for(year=5;year<=30;year++){
month=12*year;
money=cal_money(loan,rate,month);
printf("money(%d,%d)=%.0f ",loan,year,money);
}
return0;
}
『柒』 C語言問題,急,在線等
#include <stdio.h>
#include <math.h>
int main()
{float d=XXXX,p=XXXX,r=XXXX,m;
m=log10(p/(p-d*r))/log10(1+r);
printf("m=%6.2f\n",m);
return 0;
}
『捌』 C++ C語言程序設計 題目:貸款計算器
/*
* main.c
*
* Created on: 2011-6-8
* Author: icelights
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#define APR1 0.0747 /*<1年(含1年)年利率*/
#define APR2 0.0756 /*1-3年(含3年)年利率*/
#define APR3 0.0774 /*3-5年(含5年)年利率*/
#define APR4 0.0783 /*5年以上年利率*/
#define A_TO_M 1/12 /*月利率 = 年利率 / 12*/
#define RTP 12 /*Reimbursement total periods還款總期數 =年限*12*/
#define LENGTH 80
struct LoanInfo
{
/*姓名*/
char name[LENGTH];
/*貸款總額*/
double LoanAmount;
/*貸款年限*/
double LoanYear;
/*月付*/
double MonthlyPayment;
/*總利息*/
double TotalInterest;
/*還款總額*/
double ReimbursementAmount;
/*年利率*/
double apr;
struct LoanInfo * next;
};
void CalcShow(struct LoanInfo * cur, struct LoanInfo * hd,
struct LoanInfo * prv);
int main(void)
{
int temp;
struct LoanInfo * head = NULL;
struct LoanInfo * prev, * current;
current = (struct LoanInfo *)malloc(sizeof(struct LoanInfo));
if (NULL == head)
{
head = current;
}
else
{
prev->next = current;
}/*End of if (NULL == head)*/
puts("請輸入姓名");
gets(current->name);
fflush(stdin);
puts("請輸入貸款數額(單位:萬元)");
scanf("%lf", ¤t->LoanAmount);
fflush(stdin);
puts("請輸入貸款年限");
scanf("%lf", ¤t->LoanYear);
fflush(stdin);
printf("姓名:%s,貸款年限:%lf, 貸款數額%lf",
current->name, current->LoanYear, current->LoanAmount);
prev = current;
puts("請確認Y/N");
temp = getchar();
switch(toupper(temp))
{
case 'Y' : CalcShow(current, head, prev);
break;
case 'N' : free(current);
main();
break;
default : puts("輸入錯誤");
free(current);
break;
}
return 0;
}
void CalcShow(struct LoanInfo * cur, struct LoanInfo * hd,
struct LoanInfo * prv)
{
char lcv_temp;
if (cur->LoanYear <= 1)
cur->apr = APR1;
else if (cur->LoanYear <= 3)
cur->apr = APR2;
else if (cur->LoanYear <= 5)
cur->apr = APR3;
else
cur->apr = APR4;
/*End of if (year <= 1)*/
cur->LoanAmount = 10000 * cur->LoanAmount;
cur->ReimbursementAmount = cur->LoanAmount * pow((1 + cur->apr), cur->LoanYear);
cur->MonthlyPayment = cur->ReimbursementAmount / (cur->LoanYear * RTP);
cur->TotalInterest = cur->ReimbursementAmount - cur->LoanAmount;
printf("姓名:%s 貸款年限:%.0lf\n"
"貸款數額:%.2lf 每月還款額:%.2lf\n"
"利息合計:%.2lf 還款總額:%.2lf\n",
cur->name, cur->LoanYear, cur->LoanAmount,
cur->MonthlyPayment, cur->TotalInterest, cur->ReimbursementAmount);
puts("是否繼續計算Y/N");
lcv_temp = getchar();
switch(toupper(lcv_temp))
{
case 'Y' : free(cur);
main();
break;
case 'N' : free(cur);
exit(0);
default : puts("輸入錯誤");
free(cur);
main();
break;
}
system("pause");
}
『玖』 c語言 銀行貸款問題(急求)
lz ,這個問題其實是個數學公式,編程求解的話,也就是起到一個計算器的作用(如果不具備公式的話,那就只能通過枚舉來一個個嘗試了,那就失去針對性了)
剛我算了一下,思路:
1. 年利率為i ,則第一年的利息是 s * i ,第二年是 (s - 12x) * i ,其中x是每月還款額,第三年 (s - 24x) * i ... ... ,第n年的利息是 [ s - 12(n-1)x ] * i ,該等差數列之和為 [s - 6(n-1)x ] * n * i ,這就是n年所產生的總利息了。
2.通過等式 :
(總利息 + 本金)/ 年數 / 12 = 每月還款額
{ [s - 6(n-1)x ] * n * i + s } / 12n = x
解得x = ( nis + s ) / [ 12n + 6(n-1) ni ]
假設房貸 300000 按揭10年 ,利率5% ,每月還3061 ,差不多
『拾』 c語言這個問題 能幫幫忙嘛 謝謝
//希望我的回答對你的學習有幫助
#include<stdio.h>
#include<math.h>
intmain()
{
doublemoney,capital;
doublerate[4]={0.009,0.01,0.0111,0.012};
intn,m;
scanf("%lf%d",&capital,&n);
m=n/12;
if(n!=12*m){
m++;
}
if(m>3)
money=capital*pow((1+rate[3]),12*m);
else
money=capital*pow((1+rate[m-1]),12*m);
printf("%.2lf ",money);
return0;
}