#include <iostream>
#include <cstring>


using namespace std;

int numberOfDeposit, numberOfWithdrawal;
double monthlyInterestRate, monthlyInterest;
float totalAmount;
double MonthlyServiceCharge;
int selections, choices, functions;
string name, address, loginID;
int idNum, password;

class bankAccount
{
      
                

      
      public:
             bankAccount()
             {
                           float  balance;
                           double annualInterestRate;
             }
             
             float thismonthDeposit;
             float thismonthwithdrawal;
             float  balance;
              float getbalance()
              {
                    return balance;
           
                    }
      
             
             
             
             float deposit()
             {
                  cout<<"Enter the amount: "<<endl;
                  cin>>totalAmount;
                  
                  balance += totalAmount;
                  thismonthDeposit += totalAmount;
                  numberOfDeposit++;
                  
                  return balance;
                  return thismonthDeposit;
                  
                  
                  }
      
            float withdraw()
            {
                  
                  cout<<"enter the amount: "<<endl;
                  cin>>totalAmount;
                  
                  balance -= totalAmount;
                  thismonthWithdrawal += totalAmount;
                  numberOfWithdrawal++;
                  
                  return balance;
                  return thismonthWithdrawal;
                  }
                  
                  
            float calcInt()
            {
                  monthlyInterestRate = (annualInterestRate/12);
	              monthlyInterest = balance * monthlyInterestRate;
	              balance = balance + monthlyInterest;
	              
	              return balance;
                  }
                  
            virtual float monthlyProc(double MonthlyServiceCharge)
            {
                  MonthlyServiceCharge = 1;
                  balance -= MonthlyServiceCharge;
                  return balance;
                  
                  }
            
                 
            void status3()
            {
                 if(balance>25)
                 cout<<"Active account!!"<<endl;
           
                 if(balance<25)
                 cout<<"Inactive account!!!"<<endl;
           
                 }
                 
           
       void header(){
     
               cout<<"\n\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
		       cout<<"\n\n\t\t~                              ~";
               cout<<"\n\n\t\t~      WXYZ Banking System     ~";
               cout<<"\n\n\t\t~                              ~";
		       cout<<"\n\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl<<endl; 
          }


           void real()
           {
                header();
                
                cout<<"Welcome..welcome..Welcome... "<<endl;
                cout<<"Please select the following functions"<<endl;
		        cout<<"1. Withdrawal"<<endl;
		        cout<<"2. Deposit"<<endl;
		        cout<<"3. Check Balance"<<endl;
		        cout<<"4. Exit"<<endl;
		        cout<<endl;
		        cout<<"Select: "<<endl;
		        cin>>functions;
                
                }
                  
            
};

class savingAccount:virtual public bankAccount
{
      protected:
                bool accountStatus;
      public:
             savingAccount(float balance1, double annualInterestRate, float thismonthDeposit, float thismonthwithdrawal, bool accountStatus)
             : bankAccount(balance1, annualInterestRate, thismonthDeposit, thismonthwithdrawal)
                {
                                    this -> accountStatus = accountStatus;       
                             }
      
      void status1()
      {
           accountStatus = true;
           if(balance>25)
           cout<<"Active account!!"<<endl;
           bankAccount::withdraw();
           
           if(balance<25)
           cout<<"Inactive account!!!"<<endl;
           exit(0);
           
           }
      void status2()
      {
           accountStatus = true;
           if(balance>25)
           cout<<"Avtive account!!"<<endl;
           bankAccount::deposit();
           
           if(balance<25)
           cout<<"Inactive account!!!"<<endl;
           exit(0);
           
           }
           
      
      void withdraw()
      {
           status1();
           
           }
           
      void deposit()
      {
           status2();
           }
      
      
      void MSC(bankAccount *p)
      {
            cout<<"Number of withdrawal: "<<numberOfWithdrawal<<endl;
           do
           {
           cout<<"You have withdraw exceed 4 times"<<endl;
           p -> monthlyProc(MonthlyServiceCharge);
           }while(numberOfWithdrawal>4);
           
            p -> status3();
           
           }
      
           
      void registeration()
      {
           
           cout<<"Enter name: "<<endl;
           getline(cin, name);
           
           cout<<"Enter identity number: "<<endl;
           cin>>idNum;
           
           cout<<"Enter address: "<<endl;
           getline(cin, address);
           
           cout<<"Enter login id: "<<endl;
           getline(cin, loginID);
           
           cout<<"Enter password: "<<"must be numbers"<<endl;
           cin>>password;
         
           }
           
      void userlogin(bankAccount *q)
      {
           string loginID2;
           int password2;
           
           cout<<"Welcome welcome Welcome...."<<endl;
           cout<<"You are about to login: "<<endl;
           cout<<"Login ID: "<<endl;
           getline(cin,loginID);
           cout<<"Password: "<<endl;
           cin>>password2;
           
           if(loginID2 == loginID && password2 == password)
           {
                       q -> real();
             }                                         
           
           }
           
           
  };   

      
int main()
{
    bankAccount BA;
    savingAccount SA;
    
    cout<<"Welcome..welcome..welcome..."<<endl;
    cout<<"Start.."<<endl;
    cout<<"Select one of the following: "<<endl;
    cout<<"1. Register account"<<endl;
    cout<<"2. Existing account"<<endl;
    cout<<"3. Exit"<<endl;
    cin>>selections;
    
  
    
   SA.registeration();
                   
    
    
    
    
    
    cin.clear();
    cin.ignore();
    getchar();
    return 0;
    
    }

i am doing a simple bank management thingy..the program was able to compile..but when run it appear not responding..
Anyone can help me check where i did wrong?
I am new in class..so if any place wrong please point it out for me =) thx ^^

#include <iostream>
#include <cstring>


using namespace std;

int numberOfDeposit, numberOfWithdrawal;
double monthlyInterestRate, monthlyInterest;
float totalAmount;
double MonthlyServiceCharge;
int selections, choices, functions;
string name, address, loginID;
int idNum, password;

class bankAccount
{
      protected:
                
                float balance;
                double annualInterestRate;
                float thismonthDeposit;
                float thismonthWithdrawal;
      
      public:
             bankAccount(float balance1 = 0, double annualInterestRate = 0.25, float thismonthDeposit = 0, float thismonthwithdrawal = 0 )
             {
                                  this -> balance = balance1;
                                  this -> annualInterestRate = annualInterestRate;
                                  this -> thismonthDeposit = thismonthDeposit;
                                  this -> thismonthWithdrawal = thismonthwithdrawal; 
             }
             
             
              float getbalance()
              {
                    return balance;
           
                    }
      
             
             
             
             float deposit()
             {
                  cout<<"Enter the amount: "<<endl;
                  cin>>totalAmount;
                  
                  balance += totalAmount;
                  thismonthDeposit += totalAmount;
                  numberOfDeposit++;
                  
                  return balance;
                  return thismonthDeposit;
                  
                  
                  }
      
            float withdraw()
            {
                  
                  cout<<"enter the amount: "<<endl;
                  cin>>totalAmount;
                  
                  balance -= totalAmount;
                  thismonthWithdrawal += totalAmount;
                  numberOfWithdrawal++;
                  
                  return balance;
                  return thismonthWithdrawal;
                  }
                  
                  
            float calcInt()
            {
                  monthlyInterestRate = (annualInterestRate/12);
	              monthlyInterest = balance * monthlyInterestRate;
	              balance = balance + monthlyInterest;
	              
	              return balance;
                  }
                  
            virtual float monthlyProc(double MonthlyServiceCharge)
            {
                  MonthlyServiceCharge = 1;
                  balance -= MonthlyServiceCharge;
                  return balance;
                  
                  }
            
                 
            void status3()
            {
                 if(balance>25)
                 cout<<"Active account!!"<<endl;
           
                 if(balance<25)
                 cout<<"Inactive account!!!"<<endl;
           
                 }
                 
           
       void header(){
     
               cout<<"\n\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
		       cout<<"\n\n\t\t~                              ~";
               cout<<"\n\n\t\t~      WXYZ Banking System     ~";
               cout<<"\n\n\t\t~                              ~";
		       cout<<"\n\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl<<endl; 
          }


           void real()
           {
                header();
                
                cout<<"Welcome..welcome..Welcome... "<<endl;
                cout<<"Please select the following functions"<<endl;
		        cout<<"1. Withdrawal"<<endl;
		        cout<<"2. Deposit"<<endl;
		        cout<<"3. Check Balance"<<endl;
		        cout<<"4. Exit"<<endl;
		        cout<<endl;
		        cout<<"Select: "<<endl;
		        cin>>functions;
                
                }
                  
            
};

class savingAccount:virtual public bankAccount
{
      protected:
                bool accountStatus;
      public:
             savingAccount(float balance1, double annualInterestRate, float thismonthDeposit, float thismonthwithdrawal, bool accountStatus)
             : bankAccount(balance1, annualInterestRate, thismonthDeposit, thismonthwithdrawal)
                {
                                    this -> accountStatus = accountStatus;       
                             }
      
      void status1()
      {
           accountStatus = true;
           if(balance>25)
           cout<<"Active account!!"<<endl;
           bankAccount::withdraw();
           
           if(balance<25)
           cout<<"Inactive account!!!"<<endl;
           exit(0);
           
           }
      void status2()
      {
           accountStatus = true;
           if(balance>25)
           cout<<"Avtive account!!"<<endl;
           bankAccount::deposit();
           
           if(balance<25)
           cout<<"Inactive account!!!"<<endl;
           exit(0);
           
           }
           
      
      void withdraw()
      {
           status1();
           
           }
           
      void deposit()
      {
           status2();
           }
      
      
      void MSC(bankAccount *p)
      {
            cout<<"Number of withdrawal: "<<numberOfWithdrawal<<endl;
           do
           {
           cout<<"You have withdraw exceed 4 times"<<endl;
           p -> monthlyProc(MonthlyServiceCharge);
           }while(numberOfWithdrawal>4);
           
            p -> status3();
           
           }
      
           
      void registeration()
      {
           
           cout<<"Enter name: "<<endl;
           getline(cin, name);
           
           cout<<"Enter identity number: "<<endl;
           cin>>idNum;
           
           cout<<"Enter address: "<<endl;
           getline(cin, address);
           
           cout<<"Enter login id: "<<endl;
           getline(cin, loginID);
           
           cout<<"Enter password: "<<"must be numbers"<<endl;
           cin>>password;
         
           }
           
      void userlogin(bankAccount *q)
      {
           string loginID2;
           int password2;
           
           cout<<"Welcome welcome Welcome...."<<endl;
           cout<<"You are about to login: "<<endl;
           cout<<"Login ID: "<<endl;
           getline(cin,loginID);
           cout<<"Password: "<<endl;
           cin>>password2;
           
           if(loginID2 == loginID && password2 == password)
           {
                       q -> real();
             }                                         
           
           }
           
           
  };   

      
int main()
{

    cout<<"Welcome..welcome..welcome..."<<endl;
    cout<<"Start.."<<endl;
    cout<<"Select one of the following: "<<endl;
    cout<<"1. Register account"<<endl;
    cout<<"2. Existing account"<<endl;
    cout<<"3. Exit"<<endl;
    cin>>selections;
    
    
    cin.clear();
    cin.ignore();
    getchar();
    return 0;
    
    }

ok well..i delete the upcast thing..but how to call the function from savingAccount if i choose 1 for the selections..??

I will compile this in codeblocks and see what the outcome is...I will re post the code if i can help fix it, unless its solved by then. I cant compile until tonight/tommorow but I am commenting so i dont loose the thread!
Thanks, Zobadof

I will compile this in codeblocks and see what the outcome is...I will re post the code if i can help fix it, unless its solved by then. I cant compile until tonight/tommorow but I am commenting so i dont loose the thread!
Thanks, Zobadof

ok..thanks..looking forward for your advance =)

Very sorry, but you seemed to of made it so there in no user input, but obviously this wont appear as a error!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.