编程语言
首页 > 编程语言> > 浙大版《C语言程序设计实验与习题指导(第4版)》题目集 实验2-3-3 计算存款利息

浙大版《C语言程序设计实验与习题指导(第4版)》题目集 实验2-3-3 计算存款利息

作者:互联网

题目要求:

本题目要求计算存款利息,计算公式为interest=money×(1+rate)^​year
​​ −money,其中interest为存款到期时的利息(税前),money是存款金额,year是存期,rate是年利率。

输入格式:

输入在一行中顺序给出三个正实数money、year和rate,以空格分隔。

输出格式:

在一行中按“interest = 利息”的格式输出,其中利息保留两位小数。

代码:

#include <stdio.h>
#include <math.h>

int main() 
{
	double money, year, rate, interest;
	scanf("%lf %lf %lf", &money, &year, &rate);
	interest = money * pow(1+rate, year) - money;
	printf("interest = %.2f", interest);
}    

标签:lf,利息,money,C语言,rate,实验,interest,year,习题
来源: https://blog.csdn.net/hhh232323/article/details/117746642