Write a C program intrst.c that calculates the total interest income on amount Rupees 5 lakhs in a period of 10 years. Show the results for simple interest, compounded interest when the compounding is done annually, semi-annually, quarterly, monthly and daily. Assume that the interest rate is 3.5% per year.
Answers
Answer:
Compound interest is calculated by multiplying the initial principal amount by one plus the annual interest rate raised to the number of compound periods minus one.Interest can be compounded on any given frequency schedule, from continuous to daily to annually.
Taking simple interest as xinterest and compound interest as yinterest:
Explanation:
public class interest {
public void calculate(int principle, int year, double interest rate, int terms){
double xinterest = ((500000 * 3.5 * 10) / 100);
double amount = principle * Math.pow (1 + (interest rate /terms),terms * year);
double yinterest = amount - principle;
System.out.println("Simple interest on . 500000.0 in " + year + " years = Taka "+xinterest);
System.out.println("Interest on . 500000.0 in " + year + " years compounded annually = . "+yinterest);
System.out.println("Interest on . 500000.0 in " + year + " years compounded semi-annually = . "+yinterest);
System.out.println("Interest on . 500000.0 in " + year + " years compounded quarterly = . "+yinterest);
System.out.println("Interest on . 500000.0 in " + year + " years compounded monthly = . "+yinterest);
System.out.println("Interest on . 500000.0 in " + year + " years compounded daily = . "+yinterest);
}
public static void main(String args[]) {
interest obj = new interest();
obj.calculate(500000, 10, 0.035, 4); //principle: 500000, year: 10, interest: 0.035, terms: 4
}
}