Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- interface Interest{
- double p=5000, t=2, r=18;
- double SimpleInterest();
- double CompoundInterest();
- }
- class Main implements Interest{
- public double SimpleInterest(){
- return (p * t * r)/100;
- }
- public double CompoundInterest(){
- return p * (Math.pow(1+r/100, t) - 1);//principal * (Math.pow((1 + rate/100), (time * number))) - principa
- }
- public static void main (String args[]){
- Main obj = new Main();
- double ci = obj.CompoundInterest();
- double si = obj.SimpleInterest();
- System.out.println("Simple interest is "+si);
- System.out.println("Compound interest is "+ci);
- }
- }
- /*
- Simple interest is 1800.0
- Compound interest is 1961.9999999999993
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement