#include <iostream>
#include <string>
usingnamespace std;
//Global Bank object
class bank{
private:
//Class bank variables.
string name;
string initials;
string country;
char sex;
char resubmit;
int age;
int height;
//Class Account variables.
double total_savings;
double total_cheq;
double savings_amount;
double cheq_amount;
bool verify_cheq;
bool verify_saving;
public:
bank();
void register_user();
//Class for deposite/withdrawl
friendclass account;
//Class for displaying user's Card.
friendclass card;
};
bank::bank(){
total_savings = 500;
total_cheq= 500;
}
void bank::register_user(){
system("Color 1F");
cout<<"Please Fill out the Following Form: "<<endl;
cout<<"\nName: "; getline(cin,name);
cout<<"Initials: "; getline(cin,initials);
cout<<"Country of Birth: "; getline(cin,country);
cout<<"Sex ( f or m): "; cin>>sex;
cout<<"Age: "; cin>>age;
cout<<"Height: "; cin>>height;
cout<<"\nIs this accurate, would you like to re submit a form? (y or n): "; cin>>resubmit;
while(resubmit!='n'){
system("CLS");
cout<<"Please Fill out the Following Form: "<<endl;
cin.ignore();
cout<<"\nName: "; getline(cin,name);
cout<<"Initials: "; getline(cin,initials);
cout<<"Country of Birth: "; getline(cin,country);
cout<<"Sex ( f or m): "; cin>>sex;
cout<<"Age: "; cin>>age;
cout<<"Height: "; cin>>height;
cout<<"\nIs this accurate, would you like to re submit a form? (y or n): "; cin>>resubmit;
}
cout<<"Thank you for Choosing this bank, here is a complementary $500 into both your Checking and Savings Account!"<<endl;
}
class account{
public:
void deposite();
void withdrawl(char);
void verify_money(); //Make sure you do not take money out when you have $0.
};
void account::withdrawl(char s_or_c){
bank m;
if(s_or_c == 's' && m.verify_saving == true){
cout<<"Enter amount of money to withdraw: "; cin>>m.savings_amount;
m.total_savings -= m.savings_amount;
cout<<"Your Remaining Balance in your Savings Account is: "<<m.total_savings<<endl;
}
elseif(s_or_c == 'c' && m.verify_cheq == true ){
cout<<"Enter amount of money to withdraw: "; cin>>m.cheq_amount;
m.total_cheq -= m.cheq_amount;
cout<<"Your Remaining Balance in your Checking Account is: "<<m.total_cheq<<endl;
}
}
void account::verify_money(){
bank m;
if(m.total_cheq <=0)
m.verify_cheq = false;
else
m.verify_cheq = true;
if(m.total_savings <=0 )
m.verify_cheq = false;
else
m.verify_cheq = true;
}
int main(){
bank m;
account n;
int option,choice;
char s_or_c;
/*cout<<"Welcome to THE Bank!"<<endl;
m.register_user();
system("Color 2F");
system("CLS");*/
cout<<"For assistance type 1 or any number to leave: "; cin>>option;
while(option==1){
cout<<"What would you like to do?"<<endl;
cout<<"1- Withdraw money"<<endl;
cout<<"2- Deposite money"<<endl;
cin>>choice;
//Withdrwaling money
if(choice == 1){
cout<<"From Savings (s) or Chequing (c)?"<<endl;
cin>>s_or_c;
n.verify_money(); // Issue is here, compiler completely skips these two functions.
n.withdrawl(s_or_c);
}
//Depositing money
//if(choice == 2){
//}
system("CLS");
}
return 0;
}
New guy here. Hello to all. It seems to me that those member functions ARE actually being called (try setting up a cout msg in them) but then the program immediately goes back to the while loop they are nested in and the menu pops up again. Maybe nest the funcs in question in an if statement? e.g...