fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. class Bank {
  6. int account_no;
  7. int NID;
  8. int balance;
  9. //friend void interest(Bank ,Bank )
  10. public:
  11. Bank(int NID,int balance) {
  12. account_no=rand();
  13. this->NID=NID;
  14. this->balance=balance;
  15.  
  16. }
  17. ~Bank() {
  18.  
  19. }
  20.  
  21. Bank(const Bank &b) {
  22. account_no=b.account_no;
  23. NID=b.NID;
  24. balance=b.balance;
  25.  
  26.  
  27. }
  28.  
  29. void print() {
  30. cout<<"Coustomer Details :"<<endl;
  31. cout<<"Acc_no: "<<account_no<<endl<<"NID :"<<NID<<endl<<"Balance :"<<balance<<endl;
  32. }
  33. float Interest(float year) {
  34. if(year<5) return 0;
  35. if(year>5 && year<=10) return balance*.1*year;
  36. if(year>10) return balance*.2*year;
  37. }
  38. };
  39. void interest(Bank a,Bank b,int x) {
  40. float A=a.Interest(x);
  41. float B=b.Interest(x);
  42. if(A>B) {
  43. cout<<"coustomer with higher interest rate :"<<endl;
  44. a.print();
  45. }
  46. if(B>A) {
  47. cout<<"coustomer with higher interest rate :"<<endl;
  48. b.print();
  49. }
  50. if(B==A) {
  51. cout<<"coustomer with higher interest rate are :"<<endl;
  52. a.print();
  53. b.print();
  54. }
  55. }
  56.  
  57. int main()
  58. {
  59. int x,y;
  60. cout<<"Enter Data for first customer: "<<endl;
  61. cout<<"Enter NID :";
  62. cin>>x;
  63. cout<<"Enter Deposite ammount :";
  64. cin>>y;
  65. Bank A(x,y);
  66. cout<<"Enter Data for second customer: "<<endl;
  67. cout<<"Enter NID :";
  68. cin>>x;
  69. cout<<"Enter Deposite ammount :";
  70. cin>>y;
  71. Bank B(x,y);
  72. cout<<"Enter year for calculation :";
  73. int a;
  74. cin>>a;
  75.  
  76.  
  77. cout<<"*************"<<endl;
  78. A.print();
  79. cout<<"Interest rate :"<< A.Interest(a)<<endl;
  80.  
  81. B.print();
  82. cout<<"Interest rate :"<< B.Interest(a)<<endl;
  83. B.Interest(a);
  84. interest(A,B,a);
  85. }
  86.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Enter Data for first customer: 
Enter NID :Enter Deposite ammount :Enter Data for second customer: 
Enter NID :Enter Deposite ammount :Enter year for calculation :*************
Coustomer Details :
Acc_no: 1804289383
NID :5272
Balance :-300421112
Interest rate :-1.31404e+12
Coustomer Details :
Acc_no: 846930886
NID :5272
Balance :-300421112
Interest rate :-1.31404e+12
coustomer with higher interest rate are :
Coustomer Details :
Acc_no: 1804289383
NID :5272
Balance :-300421112
Coustomer Details :
Acc_no: 846930886
NID :5272
Balance :-300421112