This is my programme (work on Microsoft visual c++) and I have two question .
First, I want to say that there is no error but I need a little help.
This is a small programme about Bank :
it's work but my question is (about 6-closing account) on function closing account....
.....How could I delete the information in this function to close account by using string (I know how to delete in pointer,but
here I don't use pointer ,I want to use string) should I make it zero's (but I don't think so )
...I really need a help........
Please Help
and I have another question but not importante like the first one , that if I want to use two class in the
programme not one class , I'll make it class Bank (which have making new account & closing account & Zakat account) and the
other class is class account (which have the deposit & the withdrawal & the display of information for just one account)
Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <string> //Must include this to use class string
- using namespace std;
- class account
- {
- private:
- //int size;
- //int customer;
- string firstname,lastname,name;
- double accountbalance,amount1,amount2;
- int index;
- double zakat1,zakat;
- int num,i,month;
- /*static*/ int counter;
- public:
- account(){index=1;counter=0;cout<<"account constructor\n";}
- void newaccount();
- void closeaccount();
- void calzakat();
- ~account(){cout<<"account destrurctor\n";}
- void depositing();
- void withdrawal();
- void displayaccount();
- };
- //static int bank::counter=0;
- void account::newaccount()
- {
- cout<<"enter the customer firstname,lastname,account balance\n";
- //customer=index;
- cin>>firstname;
- cin>>lastname;
- name=firstname+lastname;
- cin>>accountbalance;
- index++;
- counter++;
- }
- void account::closeaccount()
- {
- //name=' ';
- accountbalance=00.00;
- counter--;
- /*
- for(int y=0;y<index;y++)
- {
- if((y==num)||(y>num))
- {
- customer[y]=customer[y+1];
- name[y]=name[y+1];
- accountbalance[y]=accountbalance[y+1];
- }
- }
- customer[size-1];
- name[size-1];
- accountbalance[size-1];*/
- }
- void account::calzakat()
- {
- cout<<"enter how many month is ago from last deposite money in the account th to calculate zakat\n";
- cin>>month;
- if((accountbalance>4000)&&(month>12))
- {
- zakat1=((accountbalance*2.5)/100);
- accountbalance=accountbalance-zakat1;
- cout<<" the name of the customer "<<name;
- cout<<" the account balance "<<accountbalance<<"\n"<<"the zakat is\n"<<zakat1<<"\n";
- }
- else
- {
- zakat1=00.00;
- cout<<" the name of the customer "<<name;
- cout<<" the account balance "<<accountbalance<<"\n"<<zakat1<<"\n";
- }
- zakat=zakat+zakat1;
- }
- void account::depositing()
- {
- cout<<"enter the amount you want to depositing\n";
- cin>>amount1;
- accountbalance=accountbalance+amount1;
- cout<<"the account balance after the depositing\n"<<accountbalance;
- }
- void account::withdrawal()
- {
- cout<<"enter the amount you want to withdrawal\n";
- cin>>amount2;
- if (amount2<=accountbalance)
- {
- accountbalance=accountbalance-amount2;
- cout<<"the account balance after withdrawal from it\n";
- cout<<accountbalance;
- }
- else
- cout<<"sorry..the account is less than the amount you want to withdrawal\n";
- }
- void account::displayaccount()
- {
- cout<<"the name of customer is\n"<<name<<"\nthe account balance is\n"<<accountbalance<<"\n";
- }
- int main()
- {
- int choice,accountnum,x;
- account ob[3];
- do
- {
- cout<<"enter your choice\n";
- cout<<"1-Opening a new account for a customer\n";
- cout<<"2-deposit to the account\n";
- cout<<"3-withdrawal from the account\n";
- cout<<"4-Zakat calculate and debits the account zakat\n";
- cout<<"5-display the information of account\n";
- cout<<"6-closing an account\n";
- cout<<"7-display all account information\n";
- cout<<"8-exit\n";
- cin>>choice;
- switch(choice)
- {
- case 1:
- cout<<"enter the account number from 0 to 14\n";
- cin>>accountnum;
- x=accountnum;
- cout<<"the account has the number "<<x;
- ob[accountnum].newaccount();
- break;
- case 2:
- cout<<"enter the account number from 0 to 14 to depositing it\n";
- cin>>accountnum;
- x=accountnum;
- cout<<"the account has the number "<<x;
- ob[accountnum].depositing();
- break;
- case 3:
- cout<<"enter the account number from 0 to 14 to withdrawal from it\n";
- cin>>accountnum;
- x=accountnum;
- cout<<"the account has the number "<<x;
- ob[accountnum].withdrawal();
- break;
- case 4:
- cout<<"enter the account number from 0 to 14 to calculate zakat to it\n";
- cin>>accountnum;
- x=accountnum;
- cout<<"the account has the number "<<x;
- ob[accountnum].calzakat();
- break;
- case 5:
- cout<<"enter the account number from 0 to 14 to display it\n";
- cin>>accountnum;
- x=accountnum;
- cout<<" the account that has the number "<<x;
- ob[accountnum].displayaccount();
- break;
- case 6:
- cout<<"enter the account number from 0 to 14 to close it\n";
- cin>>accountnum;
- x=accountnum;
- cout<<"the account has the number "<<x;
- ob[accountnum].closeaccount();
- break;
- case 7:
- int i;
- for(i=0;i<3;i++)
- {
- cout<<"the zakat of the account that has the number "<<i;
- ob[i].displayaccount();
- }
- break;
- case 8:
- cout<<"the exit\n";
- break;
- default:
- cout<<"invalid choice\n";
- break;
- }//end switch
- }//end while
- while(choice!=8);
- return 0;
- }
..........I need it tomorrow .... :o