write a program to accept principal,rate and time .calculate and display the interest accumulated for first year,second year and third year compound annually
Answers
Program
import java.util.Scanner;
public class CI
{
public static void main(String[] args) {
double pr = 0.0;
double r = 0.0;
double t = 0.0;
double ci = 0.0;
Scanner i = new Scanner(System.in);
System.out.print("Enter the Principal=");
pr = i.nextDouble();
System.out.print("Enter the Time Period = ");
t = i.nextDouble();
System.out.print("Enter the Interest Rate = ");
r = i.nextDouble();
ci = pr * Math.pow((1 + r/100),t);
System.out.println("Compound Interest : "+ ci);
}
}
Explanation:
Output:
Enter the Principal= 100000
Enter the Time Period =5
Enter the Interest Rate = : 9.5
Compound Interest : 157423.87409343748
Python program to calculate the Compound Interest
Program:
#Compound Interest = P(1+R/100)**t
principalamount=float(input("Enter Principal Amount : "))
rateofinterest = float(input("Enter rate of Interest : "))
timeperiod = float(input("Enter the Time Period : "))
compoundInterest=principalamount*((1+(rateofinterest/100))**timeperiod)
print("Compound Interest is : ", compoundInterest)
Input :
Enter Principal Amount : 100000
Enter rate of Interest : 8.2
Enter the Time Period : 3
Output:
Compound Interest is : 126672.33680000003
Explanation :
- Formula used : Compound Interest = P(1+R/100)**t
- Take principal amount, rate of interest and time period as inputs into three different variables.
- Apply the formula, let the computations be made and store the resulted value into a variable that represents Compound interest, print it.
Learn more :
1) What is python programming?
https://brainly.in/question/8474677
2) Python program to make a calculator.
https://brainly.in/question/14752569