复利的Java程序
复利公式:
Formula to calculate compound interest annually is given by:
Compound Interest = P(1 + R/100)r
Where,
P is principle amount
R is the rate and
T is the time span
例子:
Input : Principle (amount): 1200
Time: 2
Rate: 5.4
Output : Compound Interest = 1333.099243
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 = 10.25, time = 5;
/* Calculate compound interest */
double CI = principle *
(Math.pow((1 + rate / 100), time));
System.out.println("Compound Interest is "+ CI);
}
}
// This code is contributed by Anant Agarwal.
Please refer complete article on Program to find compound interest for more details!
在评论中写代码?请使用 ide.geeksforgeeks.org,生成链接并在此处分享链接。