public class Power
{
double pr=1;
public double pow(double no,int p)
{
while(p>0)
{
pr=pr*no;
p--;
}
return pr;
}
}
import java.io.*;
public class Ci extends Power
{
int p,t;
double r,ans;
public void input()
throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the principal");
p=Integer.parseInt(br.readLine());
System.out.println("enter the rate of interest");
r=Double.parseDouble(br.readLine());
System.out.println("Enter the time");
t=Integer.parseInt(br.readLine());
}
public void output()
{
System.out.println("the compound interest is:"+ans);
}
public void cal()
{
double h=1.0+r/100;
double res=pow(h,t);
ans=p*res-p;
}
}
import java.io.*;
public class Cimain
{
public static void main(String[] arg)
throws IOException
{
Ci c=new Ci();
c.input();
c.cal();
c.output();
}
}


No comments:
Post a Comment