C++ Program: Computing Simple Interest

 // 6 C++ program - compute simple interest and to display the result.


#include<iostream.h>

#include<conio.h>


class SimpleInterest

{

private:

float principal,rate,time,si; //Data Members

public:

void readdata( );

void compute( ); //Member Functions Declaration

void display( );

};


void SimpleInterest::readdata( ) //Member Function Definition

{

cout<<"Enter the Principal, Rate and Time"<<endl;

cin>>principal>>rate>>time;

}


void SimpleInterest::compute( ) //Member Function Definition

{

si=(principal * time * rate)/100;

}


void SimpleInterest::display( ) //Member Function Definition

{

cout<<"Principal = "<<principal<<endl;

cout<<"Time = "<<time<<endl;

cout<<"Rate = "<<rate<<endl;

cout<<"Simple Interest = "<<si<<endl;

}


void main( )

{

SimpleInterest si;

clrscr( );

si.readdata( );

si.compute( );

si.display();

getch( );

}

Comments

Popular posts from this blog

Karnataka I PUC Computer Science 2024 Study Material | SECOND PUC HANDBOOK EXAM 2025

PYTHON: Tips and Tricks