admin管理员组文章数量:1558057
Description
Suppose that the tuition for Zhongshan Universtiy is 10000 this year and tuition increases 5% every year. Write a program that reads an integer n(n>0) and uses a loop to compute the total cost of four years worth of tuition starting n years from now.
Input
An integer n (n >0)
Output
The total cost of four years worth of tuition starting n years from now.
You should set the precision to 2 and fixed.
There is a newline at the end.
Sample Input
10
Sample Output
70207.39
note:
(1)The title is a little hard to understand, to read more;
(1)If you use the POW function may result in a deviation data accuracy and the subject requirements ( because the topic specified using circular structure )
// Date:2020/3/13
// Author:xiezhg5
#include <stdio.h>
int main(void)
{
int i,n;
double j=10000.0,h,g,l,sum;
scanf("%d",&n);
for(i=1;i<=2*n;i++) //注意是循环2n次觉得很迷惑
{
j=j*1.05;
i=i+1;
}
h=j*1.05;
g=h*1.05;
l=g*1.05;
sum=j+h+g+l;
printf("%.2lf\n",sum);
return 0;
}
本文标签: FinancialLoopsLiangfuturetuition
版权声明:本文标题:[Loops]D. Liang 4.7 Financial application: computing future tuition.c 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1727384156a1112227.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论