Subscribe Our Channel

header ads

Search This Blog

Friday, July 28, 2023

Java - Calculate Compound Interest using Java Program. | JAVA PROGRAMMING | JAVA LANGUAGE

 In this code snippet we will learn how to calculate compound interest.

If Mike initially borrows an Amount and in return agrees to make n repayments per year, each of an Amount this amount now acts as a PRINCIPAL AMOUNT. While Mike is repaying the loan, interest is accumulating at an annual percentage rate, and this interest is compounded times a year (along with each payment). Therefore, Mike must continue paying these instalments of Amount until the original amount and any accumulated interest is repaid. This equation gives the Amount that the person still needs to repay after number of years.



CompoundInterest = Principal_Amount * Math.pow((1 + Interest_Rate/100), Time_Period);

import java.util.Scanner;

public class Compound_Interest {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        double Principal_Amount = 0.0;
        double Interest_Rate = 0.0;
        double Time_Period = 0.0;
        double CompoundInterest = 0.0;

        Scanner i = new Scanner(System.in);

        System.out.print("Enter the Principal Amount : ");
        Principal_Amount = i.nextDouble();

        System.out.print("Enter the Time Period : ");
        Time_Period = i.nextDouble();

        System.out.print("Enter the Interest Rate : ");
        Interest_Rate = i.nextDouble();

        CompoundInterest = Principal_Amount * Math.pow((1 + Interest_Rate / 100), Time_Period);

        System.out.println("");
        System.out.println("Compound Interest : " + CompoundInterest);
    }

}

No comments:

Post a Comment

Featured Post

Happy Republic Day Wish Using HTML and CSS | 26 January wish using HTML/CSS

 Happy Republic Day Wish Using HTML and CSS, 26 January wish using HTML/CSS <!-- WELCOME ALL OF YOU ON COMPUTER SOFT SKILLS CHANNEL -----...

Popular Posts