Implement a system for a bank. Design it so it can be used by the bank’s staff. It should enable the following:
o Opening a new account for a customer
o Closing an account
o Displaying all accounts

An Account
o Contains the name of the customer
o Contains the account balance.
o Enables withdrawal from the account
o Enables depositing to the account
o Enables taxes calculation and debits the account with the tax amount:
The balance should be checked first to see if the amount has reached the tax amount $4000. it then debits the account with 2.5 % and deposits it in the tax account (i.e. there is 1 tax account in the Bank).

here is my code:

#include  <iostream.h>
#include  <conio.h>
#include <stdlib.h>

class Customer {

   private:
      char name[20];
      char address[30];
      char city[20];
      char pcode[6];
      double acc_bal;
double tax;
   public:
      Customer:: Customer() {              // constructor
         acc_bal = 0.00;
      }

      void getdata() {
         cout << "\nEnter your name: ";    cin >> name;
         cout << "\nEnter your address: ";   cin >> address;
         cout << "\nEnter your city: ";      cin >> city;
         cout << "\nEnter your postal code: ";    cin >> pcode;
         cout << "\nEnter current account balance: ";    cin >> acc_bal;
      }

      void deposit() {
         float dep;
         cout << "\nEnter amount to be deposited: ";
         cin >> dep;
         acc_bal += dep;
      }

      void withdraw() {
         float wdraw;
         cout << "\nEnter amount to be withdrawn: ";    cin >> wdraw;
         acc_bal -= wdraw;
      }
	  
	  void taxs()
	  {

		  if(acc_bal>3999)
		 tax= acc_bal*.025;
		  else
			  cout<<"your balance has not reached the tax amount"<<endl; 
	  }

      void showdata() {
         cout << "Name: " << name;
         cout << "\nAddress: " << address;
         cout << "\nCity: " << city;
         cout << "\nPostal Code: " << pcode;
         cout << "\nAccount Balance: $" << acc_bal << endl;
		 cout<<"tax is: "<<tax<<endl;
      }

};

int main() {

   char choice;
   bool flag =0;
   int count = 0;
   int recnum;
   Customer cust[10];

   while (flag == false) {
      cout << "\t\t\n\n" << "Main Menu";
      cout << "\t\n\n" << "Select by letter:";
      cout << "\t\n" << "a - Add a customer.";
      cout << "\t\n" << "d - Deposit money.";
      cout << "\t\n" << "w - Withdraw money.";
      cout << "\t\n" << "s - Show Account Information.";
       cout << "\t\n" <<"t _ taxes.";
      cout << "\t\n" << "q - Quit Application.\n\n";
      cout << "\t" << "Choice: ";
      cin>>choice ;
      switch(choice) {
         case 'a':
            system("cls");
            if (count > 10) {
               cout << "Can't add anymore records. Press any key to return to main menu.";
               getche();
               break;
            }
            count += 1;
            cust[count].getdata();
            system("cls");
            break;

         case 'd':
            system("cls");
            cout << "\nEnter customer number: ";
            cin >> recnum;
            cust[recnum].deposit();
            system("cls");
            break;

         case 'w':
            system("cls");
            cout << "\nEnter customer number: ";
            cin >> recnum;
            cust[recnum].withdraw();
            system("cls");
            break;

         case 't':
            system("cls");
            cout << "\nEnter customer number: ";
            cin >> recnum;
            cust[recnum].taxs();
            system("cls");
            break;
         case 's':
            system("cls");
            cout << "\nEnter customer number: ";
            cin >> recnum;
            cust[recnum].showdata();
            getche();
            system("cls");
            break;
         case 'q':
            flag = 1;
            break;

         default:
            cout << "\nInvalid selection. Press a key to return to main menu.";
            getche();
      }

      if (flag == true) {
         break;
      }

   }
   return 0;
}

please help me how to make just one account for the taxes

thank you

Here's a simplistic approach.

if(acc_bal)
  tax= acc_bal*.025;
  //subtract tax from account balance to get new account balance
  //transfer tax to the the tax account for the bank.

create a Bank class to:
   hold:
     //a container to hold all Customers
     //a variable to hold running total of all taxes collected

   be able to:
     //add/remove Customers
     //display Customer data in aggregate
     //add to tax account
     //display tax account
}

I wouldn't make the tax account an instance of a customer, because then you would have to calculate a tax on the tax account when the balance in the account exceeded $4000, which doesn't make sense to me.

This article has been dead for over six months. Start a new discussion instead.