Write a program in java to calculate the amount and compound interest.
Amount= principal*(1+r/100)t
ci = amount - principal
Answers
Answered by
2
Required Answer:-
Question:
- Write a Java program to calculate amount and compound interest.
Solution:
Here comes the program.
import java.util.*;
public class Java {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
float p, r, t, a, ci;
System.out.print("Enter Principal: ");
p=sc.nextFloat();
System.out.print("Enter Rate: ");
r=sc.nextFloat();
System.out.print("Enter Time: ");
t=sc.nextFloat();
a=p*(float)Math.pow(1+r/100.0, t);
System.out.println("Amount: "+a);
ci=a-p;
System.out.println("Compound Interest: "+ci);
sc.close();
}
}
Algorithm:
- START.
- Accept principal, rate and time.
- Calculate amount and compound interest.
- Display the result.
- STOP.
See the attachment for output ☑.
Attachments:
Answered by
1
Principal Amount Formulas
We can rearrange the interest formula, I = PRT to calculate the principal amount. The new, rearranged formula would be P = I / (RT), which is principal amount equals interest divided by interest rate times the amount of time.
fine an u
how's ur study bestu
Similar questions