寻找复利的程序

什么是“复利”? 复利 指贷款或存款本金加上的利息,或者换句话说,利息。它是利息再投资的结果,而不是支付利息,因此下一个时期的利息将由本金加上之前累计的利息赚取。复利是金融和经济学中的标准利率。 复利可能与单利形成对比,单利的利息不计入本金,因此没有复利。 复利公式:

null

每年计算复利的公式如下: 金额=P(1+R/100) T

复利=金额–P 哪里 P是原则金额 R是速率和 T是时间跨度

伪代码:

Input principle amount. Store it in some variable say principle.Input time in some variable say time.Input rate in some variable say rate.Calculate Amount using formula, Amount = principle * (1 + rate / 100)  time).Calculate Compound Interest using Formula.Finally, print the resultant value of CI.

例子:

Input : Principle (amount): 1200        Time: 2        Rate: 5.4Output : Compound Interest = 133.099243

C++

// CPP program to find compound interest for
// given values.
#include <bits/stdc++.h>
using namespace std;
int main()
{
double principle = 10000, rate = 5, time = 2;
/* Calculate compound interest */
double A = principle * ( pow ((1 + rate / 100), time ));
double CI = A- principle;
cout << "Compound interest is " << CI;
return 0;
}
//This Code is Contributed by Sahil Rai.


JAVA

// Java program to find compound interest for
// given values.
import java.io.*;
class GFG
{
public static void main(String args[])
{
double principle = 10000 , rate = 5 , time = 2 ;
/* Calculate compound interest */
double A = principle *
(Math.pow(( 1 + rate / 100 ), time));
double CI = A - principle;
System.out.println( "Compound Interest is " + CI);
}
}
//This Code is Contributed by Sahil Rai.


Python3

# Python3 program to find compound
# interest for given values.
def compound_interest(principle, rate, time):
# Calculates compound interest
A = principle * ( pow (( 1 + rate / 100 ), time))
CI = A - principle
print ( "Compound interest is" , CI)
compound_interest( 10000 , 5 , 2 )
#This Code is Contributed by Sahil Rai.


C#

// C# program to find compound
// interest for given values
using System;
class GFG {
// Driver Code
public static void Main()
{
double principle = 10000, rate = 5, time = 2;
// Calculate compound interest
double A = principle * (Math.Pow((1 +
rate / 100), time));
double CI = A - principle;
Console.Write( "Compound Interest is " + CI);
}
}
//This Code is Contributed by Sahil Rai.


PHP

<?php
// PHP program to find
// compound interest for
// given values.
$principle = 10000;
$rate = 5;
$time = 2;
// Calculate compound interest
$A = $principle * (pow((1 +
$rate / 100), $time ));
$CI = $A - $principle ;
echo ( "Compound interest is " . $CI );
?>


Javascript

<script>
// JavaScript program to
// find compound interest for
// given values.
let principle = 10000, rate = 5,
time = 2;
/* Calculate compound interest */
let A = principle *
(Math.pow((1 + rate / 100), time));
let CI = A - principle;
document.write( "Compound interest is " + CI);
</script>
// This Code is Contributed by Sahil Rai.


输出:

Compound interest is 1025
© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享