1161 Problem J "C Programming Language" Jiang Po Kushiro Editor - Exercises 3-9- compound interest

Problem Description

According to the bank's current interest rate table, enter the deposit amount from the keyboard money, deposit period year and annual interest rate, calculate the principal and interest on bank deposits
is calculated as: SUM = Money (1 + Rate) year , SUM is the total principal and interest, to retain an output decimals.
Printed book is wrong, year should index.

Entry

Bold Style

Export

Bold Style

Sample input

10000 5 0.1

Sample Output

16105.1

AC Code

#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main()
{
    double money,rate,sum;
    int year;
    cin >> money >> year >> rate;
    sum = money * pow(1 + rate, year);
    printf("%.1f",sum);
    return 0;
}
Published 119 original articles · won praise 28 · views 40000 +

Guess you like

Origin blog.csdn.net/weixin_41179709/article/details/103956529