當前位置:首頁 » 編程語言 » c語言房貸計算器

c語言房貸計算器

發布時間: 2022-06-16 10:16:38

『壹』 有關銀行貸款還貸的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語言程序編寫下面題目,貸款計算器。

現在改好,看到變化的地方:

#包括中

無效的主要(無效)

{

持股量A,B,面積;/ *應被宣布為float * /

:浮動get_area(浮動,浮動,浮動);/ *正常申報的法律,有正式的和實際參數不能相同的名稱* /

printf的(「請輸入一個梯形的上底:\ n」);

scanf的(「%f」,&A);

輸出(「請輸入一個梯形下底:\ n」);

scanf的(「%f」,及b); printf的(「請輸入梯形的高

:\ n」);

scanf的(「%f」,&H);/ *變化* /

面積= get_area(A,B,H);

printf(「請梯形面積是%f \ n 「,區);

}

的持股量get_area(浮動a_x,b_x浮,浮H_X)

{

回報1/2.0 *(a_x + b_x)* H_X; / * 2更改為2.0,因為1/0,1/2 = 2.0 = 0.5,這是想法?C * /
}

『叄』 用c++設計一個房貸計算器,在輸入貸款總額,貸款年利率以及借貸月數後,能更具上述公式計算每月還款額

貸款月數和還款次數相等?我不是很清楚那個還款,我的演算法是每一個月還款剩餘的本金在計算每月本金的,也就是說每月本金不相同,你可以把問題描述的更加詳細點,我在給修改修改

# include<iostream>

using namespace std;

int main()

{

int a,n,i; //a表示貸款金額 n代表借貸月數

float k,s,p,q,m; //k代表年利率 s代表每月還款額 p代表每月本金 q代表每月利息 m表示上月本金

cout<<"請輸入貸款金額"<<"a=";

cin>>a;

cout<<"請輸入借貸月數"<<"n=";

cin>>n;

cout<<"請輸入年利率"<<"k=";

cin>>k;

for(i=1;i<=n;i++)

{

p=a/n;

m=a-(p*i);

q=m*(k/12);

s=p+q;

cout<<"第"<<i<<"個月的還款金額為"<<"s="<<s<<endl;

a-=s;

}

return 0;

}


我運行試了,你看看可以不可以,不可以的話我在給改改

『肆』 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語言貸款計算器的設計題

下面的程序是結合你的程序修改的,公式計算部分,你自己修改一下,因為我實在看不懂上面你貼出的公式,格式太亂了。
//貸款利率計算器。
#include<stdio.h>
#include<math.h>
void inputData(char c[],float *a,int *y) //姓名,貸款數額和年限
{
char ch;
while(1)
{
printf("輸入用戶姓名:\n");
scanf("%s",c);
getchar();
printf("輸入貸款數額(萬元):\n");
scanf("%f",a);
getchar();
printf("輸入貸款年限:\n");
scanf("%d",y);
getchar();
printf("姓名:%s,貸款年限為%d年,貸款數額為%f萬元,正確?(Y/N)\n",c,*y,*a);
scanf("%c",&ch);
getchar();
if(ch == 'Y' || ch =='y')
{
break;
}
}

}
float getliLv(int y) //獲得年利率。
{
float x=0.0;
switch(y)
{
case 0:
case 1:
{
x=0.0747;
break;
}
case 2:
case 3:
{
x=0.0756;
break;
}
case 4:
case 5:
{
x=0.0774;
break;
}
default:
{
x=0.0783;
}
}
return x;
}

int main()
{
char c[30]; //姓名
int year; //年限
float a; //貸款總額。
float lilv; //年利率
double monthR; //每月還款額
double lixisum; //利息合計
double sumE; //還款總額。
double k,l;
char ch;
printf("*********************貸款利率計算系統*****************\n");
while(1)
{
inputData(c,&a,&year);
lilv = getliLv(year);
//注意,下面的計算可能存在問題,因為我實在看不懂你的計算公式,你根據公式改變一下吧。
k=lilv/12*pow((1+lilv/12),(year*12));
l=pow((1+lilv/12),(year*12-1));
monthR=k/l*a*10000;
lixisum=a*lilv*year*10000;
sumE=monthR*year*12; //每月還款額*還款期數
printf("姓名:%s 貸款年限(年):%d\n貸款數額(元):%f 每月還款數額(元):%f\n利息合計(元):%f 還款總額(元):%f\n",c,year,a*10000,monthR,lixisum,sumE);
printf("是否進行新的計算(Y/N)?\n");
scanf("%c",&ch);
getchar();
if(ch != 'Y' && ch != 'y')
{
break;
}

}
return 0;
}

『陸』 c語言初學者虛心求教銀行貸款計算器

1. 第一個scanf裡面&a&b&c之間要有逗號,應該是&a,&b,&c
2. 第二個scanf("%c\n,&f);在\n後面少了後引號,應該是scanf("%c\n",&f);
3. (int)f-(int)e==0的用法不對,應該是f=='e',才表示當f輸入的是e時
4. scanf裡面最好不要有\n,不然容易輸入錯誤

然後你功能好像還沒做完吧,最後輸出的是什麼也不知道啊
另外建議最前面三個值輸入的時候最好分開寫,不要在一起,然後每輸入一個值輸出顯示一次,保證正確

『柒』 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++房貸計算器

這不是財富能給寫的 你可以到CSDN上搜搜相關代碼

『玖』 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語言代碼編寫的計算器程序,怎麼變成有這種界面的樣子

這一「變」可費大勁了,沒有大毅力者做不出來。

  1. 不能用C,得用C++

  2. 不能用控制台,得用MFC

  3. 邏輯關系比你現有的這個程序復雜10倍

如果你還想做,我就給你找個教程。

熱點內容
android開啟wifi 發布:2025-02-06 23:50:08 瀏覽:495
騰訊雲伺服器是不是只有c盤 發布:2025-02-06 23:50:03 瀏覽:472
安卓如何選擇相冊 發布:2025-02-06 23:49:57 瀏覽:345
安卓究極風暴4在哪個軟體可以玩 發布:2025-02-06 23:49:10 瀏覽:8
如何調用伺服器的視頻 發布:2025-02-06 23:48:57 瀏覽:641
編程粉絲名 發布:2025-02-06 23:48:56 瀏覽:559
區域網存儲安裝 發布:2025-02-06 23:42:50 瀏覽:926
androidbug 發布:2025-02-06 23:31:56 瀏覽:51
php數字判斷 發布:2025-02-06 23:17:40 瀏覽:41
優路教育伺服器連接不上怎麼回事 發布:2025-02-06 23:03:49 瀏覽:141