Sunday, 12 March 2023

9. A bank gives 6.5% per annum interest on deposits made in that bank. Write a program to calculate the total amount that a person will receive after the end of 5 years for a deposit of Rs.5000 for compound interest. Create necessary methods and constructors too.

 



class Cintrest
{
    double p,r,n;
    double ci;
   
    Cintrest(double p1,double r1,double n1)
    {
        p = p1;
        r = r1;
        n = n1;
    }
   
    double calculate_intrest()
    {
        ci = p * (Math.pow((1+ (r/100)),n));
        return ci;
    }
}

class Program9
{
    public static void main(String args[])
    {
        double p=5000,r=6.5,n=5;
       
        Cintrest obj = new Cintrest(p,r,n);
       
        System.out.println("compound intrest: " + obj.calculate_intrest());
    }
}


No comments:

Post a Comment

python programs

1. sum of two number