Advertisement
vvccs

Bank transfer using friend function

Jun 6th, 2023
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.74 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class bank
  4. {
  5. public:
  6.     double id, id1;
  7.     double money, money1;
  8.     double acc, acc1, m, t, t1;
  9.     friend int data(bank);
  10.     friend int data1(bank);
  11. };
  12. int data(bank i)
  13. {
  14.     cout << "Enter HDFC account number please: ";
  15.     cin >> i.acc;
  16.     if (i.id1 == i.acc)
  17.     {
  18.         cout << "[your account number is match]";
  19.         cout << "\nEnter money to transfer: ";
  20.         cin >> i.m;
  21.         if (i.m <= i.money)
  22.         {
  23.             cout << "[Money has been successfully transfer]\n";
  24.             i.t = i.money - i.m;
  25.             cout << "-----------------SBI DETAIL---------------\n";
  26.             cout << "SBI Account No |" << i.id << endl
  27.                  << "Previous Balance |" << i.money << endl;
  28.             cout << "Transfered Money |" << i.m << endl
  29.                  << "Available Balance |" << i.t << endl;
  30.             cout << "--------------------------------------------\n";
  31.             i.t = i.money1 + i.m;
  32.             cout << "-----------------HDFC DETAIL----------------\n";
  33.             cout << "HDFC Account No |" << i.id1 << endl
  34.                  << "Previous Balance |" << i.money1 << endl;
  35.             cout << "Received Money |" << i.m << endl
  36.                  << "Available Balance |" << i.t << endl;
  37.             cout << "--------------------------------------------\n";
  38.         }
  39.         else
  40.         {
  41.             cout << "That Much Money not available in your account\n";
  42.         }
  43.     }
  44.     else
  45.     {
  46.         cout << "Enter valid account number\n";
  47.     }
  48. }
  49. int data1(bank i)
  50. {
  51.     cout << "Enter SBI account number please\n";
  52.     cin >> i.acc;
  53.     if (i.id == i.acc)
  54.     {
  55.         cout << "[your account number is match]\n";
  56.         cout << "Enter money to transfer \n";
  57.         cin >> i.m;
  58.         if (i.m <= i.money1)
  59.         {
  60.             cout << "[Money has been successfully transfer]\n";
  61.             i.t1 = i.money1 - i.m;
  62.             cout << "-----------------HDFC DETAIL----------------\n";
  63.             cout << "HDFC Account No |" << i.id1 << endl
  64.                  << "Previous Balance |" << i.money1 << endl;
  65.             cout << "Transfered Money |" << i.m << endl
  66.                  << "Available Balance |" << i.t1 << endl;
  67.             cout << "--------------------------------------------\n";
  68.             i.t1 = i.money + i.m;
  69.             cout << "-----------------SBI DETAIL---------------\n";
  70.             cout << "SBI Account No |" << i.id << endl
  71.                  << "Previous Balance |" << i.money << endl;
  72.             cout << "Received Money |" << i.m << endl
  73.                  << "Available Balance |" << i.t1 << endl;
  74.             cout << "--------------------------------------------\n";
  75.         }
  76.         else
  77.         {
  78.             cout << "That Much Money not available in your account\n";
  79.         }
  80.     }
  81.     else
  82.     {
  83.         cout << "Enter valid account number\n";
  84.     }
  85. }
  86. int main()
  87. {
  88.     bank i;
  89.     cout << "Set account number for SBI: ";
  90.     cin >> i.id;
  91.     cout << "\nEnter money in SBI bank account: ";
  92.     cin >> i.money;
  93.     cout << "\nSet account number for HDFC: ";
  94.     cin >> i.id1;
  95.     cout << "\nEnter money in HDFC bank account: ";
  96.     cin >> i.money1;
  97.     cout << "-------------------------\n";
  98.     cout << "SBI Account No |" << i.id << endl
  99.          << "Available Balance |" << i.money << endl;
  100.     cout << "HDFC Account No |" << i.id1 << endl
  101.          << "Available Balance |" << i.money1 << endl;
  102.     cout << "-------------------------\n";
  103.     int ch;
  104.     cout << "\n1.SBI to HDFC\n";
  105.     cout << "2.HDFC to SBI\n";
  106.     cout << "Select Bank to transfer money: ";
  107.     cin >> ch;
  108.     switch (ch)
  109.     {
  110.     case 1:
  111.         data(i);
  112.         break;
  113.     case 2:
  114.         data1(i);
  115.         break;
  116.     }
  117. }
  118.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement