ADVERTISEMENT
ADVERTISEMENT

Java - Calculate Compound Interest using Java Program.

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);

Java Code Snippet - Calculate Compound Interest using Java Program

import java.util.Scanner;
 
public class Compound_Interest {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
 
        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);       
    }
 
}

Output

    Enter the Principal Amount : 100000
    Enter the Time Period : 5
    Enter the Interest Rate : 9.5

    Compound Interest : 157423.87409343748

Java Basic Programs »


ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.