Advertisement
LEO0506

Untitled

Mar 18th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.21 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3.                              LEONARDO T.M. VIEIRA
  4.                              A NEW BANK
  5.  
  6. *******************************************************************************/
  7. #include <iostream>
  8. #include <locale.h>
  9. #include <cstdlib>
  10. #include<time.h>
  11. #include<ctype.h>
  12. #include<string>
  13. using namespace std;
  14.  
  15. class BA
  16. {
  17.   public:
  18.     string verify= "You don't have enough money!";
  19.     string warm= "Maximum value!(400)";
  20.     int client;
  21.  
  22.  
  23.  
  24.  
  25.     void set_money(int j)
  26.     {
  27.                 money=j;
  28.     }
  29.  
  30.     int get_money()
  31.     {
  32.          return money;
  33.     }
  34.  
  35.     BA (string something)
  36.     {
  37.             money= data_name(something);
  38.     }
  39.  
  40.     ~BA ()
  41.     {
  42.  
  43.     }
  44.  
  45.     void credit (int value)
  46.     {
  47.             if (warning(value))
  48.         {
  49.             money=value+money;
  50.             cout<<", your new balance is:"<<endl;
  51.             cout<<get_money()<<endl;
  52.         }
  53.  
  54.             else
  55.         {
  56.             cout<<", Please, try another different value."<<endl;
  57.             cout<<warm<<endl;
  58.         }
  59.     }
  60.  
  61.     void debit (int x)
  62.     {
  63.             if (verification(x))
  64.             {
  65.                 cout<<", your new balance is:"<<endl;
  66.                 money=money-x;
  67.                 cout<<get_money()<<endl;
  68.             }
  69.  
  70.             else
  71.             {
  72.                 cout<<", please, try another different value."<<endl;
  73.                 cout<<"\n"<<verify<<"\n";
  74.             }
  75.     }
  76.  
  77.   private:
  78.   int money;
  79.  
  80.   int data_name(string something)
  81.     {
  82.         int pop=0;
  83.         int i;
  84.         std::getline(std:: cin, something);
  85.         for (i=0; i<something.length(); i++)
  86.         {
  87.             pop+=(int)something[i];
  88.  
  89.         }
  90.         return pop;
  91.     }
  92.  
  93.     int warning (int value)
  94.     {
  95.                 if (value>400)
  96.                 {
  97.                     return 0;
  98.                 }
  99.  
  100.                 else
  101.                 {
  102.                     return 1;
  103.                 }
  104.     }
  105.  
  106.       int verification (int x)
  107.     {
  108.                 if (money>=x)
  109.                 {
  110.                     return 1;
  111.                 }
  112.                 else
  113.                 {
  114.                     return 0;
  115.                 }
  116.     }
  117. };
  118.  
  119. int main()
  120. {
  121.  
  122.     char option;
  123.     int u;
  124.     int v;
  125.     char D;
  126.     string something;
  127.  
  128.  
  129.     cout<<"Welcome to the bank!!!"<<endl;
  130.     cout<<"\nWhat's your name?"<<endl;
  131.     std::getline(std:: cin, something);
  132.     BA b (something);
  133.     BA b1 (something);
  134.  
  135.  
  136.     cout<<"\nPlease, press an option bellow"<<endl;
  137. do
  138.     {
  139.     cout<<"[A,B,C,0]"<<endl;
  140.     cout<<"\n\tA=showing your money\n\tB=adding credit in your account (maximum 400),\n\tC=debiting from your account \n\tD= close your bank account"<<endl;
  141.     cin>> option;
  142.     if (option=='a'||option=='b'||option=='c'||option=='d')
  143.             {
  144.                 option=toupper(option);
  145.             }
  146.     switch(option)
  147.     {
  148.         case 'A':
  149.         {
  150.                 cout<<"\n"<<something;
  151.                 cout<<", your balance is:"<<endl;
  152.                 cout<<b.get_money()<<endl;
  153.                 break;
  154.         }
  155.  
  156.         case 'B':
  157.         {
  158.                 cout<<"How much do you want to credit?"<<endl;
  159.                 cin>>v;
  160.                 cout<<"\n"<<something;
  161.                 b.credit(v);
  162.                 break;
  163.         }
  164.  
  165.         case 'C':
  166.         {
  167.                 cout<<"How much do you want to debit?"<<endl;
  168.                 cin>>u;
  169.                 cout<<"\n"<<something;
  170.                 b.debit(u);
  171.                 break;
  172.         }
  173.         default:
  174.             if (option=D)
  175.             {
  176.  
  177.                 cout<<"\n"<<something;
  178.                 cout<<", you've closed your bank account. Thanks for coming today!"<<endl;
  179.  
  180.                 system("cls");
  181.                 cout<<"Welcome to the bank!!!"<<endl;
  182.                 cout<<"\nWhat's your name?"<<endl;
  183.                 cin>>something;
  184.                 //std::getline(std:: cin, name);
  185.  
  186.             }
  187.             else
  188.             {
  189.                 cout<<"\n"<<something;
  190.                 cout<<", please, insert an option bellow"<<endl;
  191.             }
  192.     }
  193.  }
  194. while(b1.client!=2);
  195. return 0;
  196.  
  197. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement