int main()
{
double m,sum//m借钱数 sum终利息本金颂旁
int i=0
printf("请输宏仿入借钱数野绝橡:")
scanf("%lf",&m)//float应%f,double应%lf,int应%d
sum=m
for( i=0i<30i++ )
{
m *= 0.0005 //借款*利率
sum += m //借款余额
m=sum
}
printf("30利息:%lf\n",sum)
return 0
}
我刚写档岁的,希望对你有所帮助。#include<stdio.h>
double BenXi(int year,double money)
int main()
{
int year
double money,benxi
do
{
printf("please input the years you save money and the amounts of money:\n")//输入存指耐期和存款额
scanf("%d%lf",&year,&money)
}while(year>5||year<行逗睁1||money<=-0.0000000001)
benxi=BenXi(year,money)
printf("%lf\n",benxi)
return 0
}
double BenXi(int year,double money)
{
double lilv=0
double benxi
switch(year)
{
case 1:lilv=2.25/100break
case 2:lilv=2.7/100break
case 3:lilv=3.24/100break
case 5:lilv=3.6/100break
default:break
}
benxi=money*(1+lilv)
return benxi
}
以下程序行尺亏就能完成档神任务了/*
输入存款金额
money、存期
year
和年利率
rate,根据下列公式计算存款到期时的利息
interest(税前),输出时保留2位小数。
interest
=
money(1+rate)^year
-
money
输入输出示例:括号内为说明
输入
1000
3
0.025
(money
=
1000,
year
=
3,
rate
=
0.025)
输出
interest
=
76.89
*/
#include
#include
int
main(void)
{
int
money,
year
double
interest,
rate
//printf("type
in
money:")
scanf("%d",&money)
scanf("%d",&year)
scanf("%lf",&rate)
interest
=
money
*
pow((1+rate),year)
-
money
//pow就是计算x^y的函数
printf("interest
=
%.2f\困罩n",
interest)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)