Java Program to calculate Compound Interest

JavaObject Oriented ProgrammingProgramming

Following is the program to calculate Compound Interest in Java −

Example

 Live Demo

import java.io.*;
public class Demo{
   public static void main(String args[]){
      double princ = 456000, rt = 9.75, tm = 7;
      double comp_int = princ *(Math.pow((1 + rt / 100), tm));
      System.out.println("The compound interest for the given principle amount, rate and time is "+          comp_int);
   }
}

Output

The compound interest for the given principle amount, rate and time is 874573.9655622267

A class named Demo contains the main function wherein a principal value, a rate and a time are initialized. The formula for compound interest, principal * ((1 + rate/100) power time) is initialized to a value and the output is calculated. This is displayed on the console.

raja
Published on 04-Jul-2020 13:23:09
Advertisements