C and C++

C++ program for the simple interest using dynamic initialization

C++
#include<iostream.h>

#include<conio.h>

class SI{

        int P, T;

        float R, Interest;

    Public:

        SI(){

        }

    SI(int P1, int T1, float R1)

    {

        P=P1;

        T=T1;

        R=R1;

        Interest=(P*T*R)/100;

    }

    float

    {

        return(Interest);

    }

};

//-----------------------------------------

void main()

{

    SI s1;

    int p,t;

    float r;

    clrscr();

    cout<<"----------------------------------------\n";

    cout<<"Enter the value for Principal amount:";

    cin>>p;

    cout<<"\n Enter the value for time:";

    cin>>t;

    cout<<"\n Enter the value for rate:";

    cin>>r;

    cout<<"\n ---------------------------------\n";

    s1=SI(p,t,r);

    cout<<"The Simple Interest ="<<s1.show()<<endl;

    cout<<"--------------------------------------\n";

    getch();

}

[wp_ad_camp_1]

OUTPUT:

-----------------------------------

Enter the value for Principal amount: 4515

Enter the value for time: 5

Enter the value for rate: 10.8

------------------------------------

The Simple Interest = 2438.100098

------------------------------------

-----------------------------------

Enter the value for Principal amount: 3000

Enter the value for time: 4

Enter the value for rate: 5.5

------------------------------------

The Simple Interest = 660

------------------------------------

Leave a comment

Your email address will not be published. Required fields are marked *