Write a program for bank which has class bank,deposit,withdraw in cp

  1. #include<iostream>
  2. using namespace std;
  3. static long int id;
  4. class bank{
  5. protected:
  6. char name[10];
  7. double money=2000;
  8. int acc_no;
  9. public:
  10. void setdetails(){
  11. cout<<"\n Enter name :";
  12. cin>>name;
  13. cout<<"\nyour acc_no(PLEASE NOTE DOWN) : "<<id;
  14. acc_no=id;
  15. id++;
  16. cout<<"\n you have to deposite '2000rs' for opening account in pruthvi bank\n THANK YOU";
  17. cout<<"\nPlease keep balance above 2000rs";
  18. }
  19. };
  20. class deposite:virtual public bank{
  21. public:
  22. void set_deposit(){
  23. float temp;
  24. cout<<"\n Enter deposite value : ";
  25. cin>>temp;
  26. money=money+temp;
  27. cout<<"\n Now money : "<<money<<endl;
  28. }
  29. };
  30. class withdrawl:virtual public bank{
  31. public:
  32. void set_with(){
  33. float temp;
  34.  
  35. cout<<"\n Enter withdrawl value : ";
  36. cin>>temp;
  37. if((money-temp)>2000){
  38. money=money-temp;
  39. }
  40. else {
  41. cout<<"\nyou cant withdrawl";
  42. }
  43. cout<<"\n Now money : "<<money<<endl;
  44. }
  45. };
  46. class child:public deposite,public withdrawl{
  47. public:
  48. void printd(){
  49. cout<<"\n your name : "<<name<<"\n your account no : "<<acc_no<<"\n money="<<money;
  50. }
  51. };
  52.  
  53. int main(){
  54. child p[100];
  55. char ch;
  56. long i;
  57. int choice;
  58. do{
  59. label:
  60. cout<<"\n1.create account\n2.deposite\n3.withdrawl\n4.details\n choice : ";
  61. cin>>choice;
  62. switch(choice){
  63. case 1:p[id].setdetails();break;
  64. case 2:
  65. cout<<"Enter id : ";cin>>i;
  66. p[i].set_deposit();
  67. break;
  68. case 3:
  69. cout<<"Enter id : ";cin>>i;
  70. p[i].set_with();
  71. break;
  72. case 4:
  73. cout<<"Enter id : ";cin>>i;
  74. p[i].printd();
  75. break;
  76. default:
  77. goto label;
  78. }
  79. }
  80. while(1);
  81. return 0;
  82. }
  83.  

Comments

Popular posts from this blog

Introduction to ChatGPT: Explain what ChatGPT is, how it works, and what it is used for.

Multi Level Inheritance In cpp

Hybrid Inheritance In cpp