Principal amount |
Rate of interest |
Rs 1 – Rs 999 | 2% of principal amount |
Rs 1000 – Rs 2999 | 3% of principal amount |
Rs 3000 – Rs 5999 | 5% of principal amount |
Rs 6000 and above | 8% of principal amount |
Print customer number and calculated simple interest of all 100 customer.
#include<iostream.h> #include<conio.h> class customer { private: int cn; float p,r,t,si; public: void input() { cout<<"Enter customer No:- "; cin>>cn; cout<<"Enter Principal Amount:- "; cin>>p; cout<<"Enter Time in Year:- "; cin>>t; } void calculate(); void output() { cout<<"Customer No:- "<<cn<<endl; cout<<"Simple Interest:- "<<si<<endl; } }; void customer::calculate() { if(p>=1 && p<=999) r=2; else if(p>=1000 && p<=2999) r=3; else if(p>=3000 && p<=5999) r=5; else r=8; si=(p*r*t)/100; } void main() { int i; customer c; clrscr(); for(i=0;i<100;i++) { c.input(); c.calculate(); c.output(); } getch(); }
Advertisements