我正在尝试编写这个程序来计算存款的简单利息.它应该将利息金额加到原始存款上.
但它继续使变量"速率"0,这就是为什么当我运行它,结果为0.任何帮助表示赞赏.
#include <stdio.h>
int main(void){
double d;
double rate;
double y;
double final;
int x;
printf("Enter the deposit: ");
scanf("%d", &d);
printf("Enter the interest rate (0-100): ");
scanf("%d", &rate);
printf("Enter the number of years: ");
scanf("%i", &x);
rate = rate / 100;
y = d * rate * x;
final = d + y;
printf("After %i number of years, the deposit in the savings account is now %d", x, rate);
}
Run Code Online (Sandbox Code Playgroud)