Testing environment: Visual Studio 2010 Ultimate.
Hopefully my question was clear enough--my objective is to have a user select an option
1. Enter 1 for Chequing
2. Enter 2 (or any number) for Savings
so whichever option the users chooses, the program will print "Account Type: Chequing [or] Savings
"
I've managed to accept the user's input and get half of what I was trying done. My issue is any number i choose, an additional number gets printed, see picture.
http://ift.tt/1zZwGbe (picture from previous build, fixed the selection issue, but the additional number still gets printed under ACCOUNT TYPE)
my account.cpp (include account.h):
int Account::WhichOne(int actype)
{
if (actype == 1)
{
cout << "Account Type: Chequing" << endl;
}
else
cout << "Account Type: Savings" << endl;
return actype;
};
my main.cpp
int main()
{
char firstName[255];
char lastName[255];
char sinNumber[255];
double balance = 0;
int choice;
int checker;
int accountType = 0;
int transactions = 0;
//Retrieve client information
cout << "Please fill out the information below for registration:" << endl;
cout << "Enter first name: ";
cin.getline(firstName, 255);
cout << "Enter last name: ";
cin.getline(lastName, 255);
cout << "Enter SIN number: ";
cin.getline(sinNumber, 255);
cout << "Enter initial balance: ";
cin >> balance;
cout << "Enter account type:\n Chequing - 1\n Savings - 2\n Choice: ";
cin >> choice;
cout << "\nPlease wait..." << endl;
//Creating the account
Account account(firstName, lastName, sinNumber, balance, accountType, transactions);
double deposit;
double withdraw;
double amount;
double ammount;
cout << "Amount to deposit: ";
cin >> amount;
deposit = account.DepositAmt(amount);
cout << "Your new balance is: " << deposit << endl;
cout << "Amount to withdraw: ";
cin >> ammount;
deposit = account.WithdrawAmt(ammount);
cout << "Your new balance is: " << deposit << endl;
accountType = account.WhichOne(choice);
cout << "" << accountType << endl;
}
I'm really not sure what to do. I'm positive my issue with the return actype
but no matter what return value i put there it gets printed as well.
Aucun commentaire:
Enregistrer un commentaire