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