WAP to calculate simple interest using class (Display principal, rate and time along with simple interest)
#include <iostream>
#include <iomanip>
using namespace std;
class Interest{
public:
double principal;
double rate,simpleInterest;
int time;
void display(){
cout<<"Enter the principal value: ";
cin>>principal;
cout<<"Enter the rate: ";
cin>>rate;
cout<<"Enter the time taken: ";
cin>>time;
cout<<"Display principal, rate and time: "<<principal<<setw(20)<<rate<<setw(20)<<time<<endl;
simpleInterest=rate/100*principal*time;
cout<<"The interest is: "<<simpleInterest;
}
};
int main()
{
Interest s;
s.display();
return 0;
}
Comments
Leave a comment