Write a Program TO DECLARE A CLASS 'SimpleInterest' and calculate simple interest for 2 object

/*
   WAP TO DECLARE A CLASS 'SimpleInterest' and calculate simple interest for 2 object
*/
#include<iostream>
using namespace std;
class SimpleInterest
{
    int noy;//noy= number of year
    float roi,pa;//roi=rate of interest pa=principle amount

    public:
            SimpleInterest(float pa,int noy,float roi=11.5)
            {
                this->pa=pa;
                this->noy=noy;
                this->roi=roi;
            }

            void calulate()
            {
                int si;//si=simple interest
                si=(pa*noy*roi)/100;
                cout<<"\n\n Simple Interest= "<<si;
            }

};

int main()
{
    int noy;//noy= number of year
    float pa;//pa=principle amount

    cout<<"\n\n Enter Principle Amount, Number of Year: ";
    cin>>pa>>noy;

    SimpleInterest S(pa,noy);

    S.calulate();

    cout<<"\n\n Enter Principle Amount, Number of Year: ";
    cin>>pa>>noy;

    SimpleInterest S1(pa,noy);

    S1.calulate();

    return 0;
}

Previous
Next Post »