I am doing a project for school and keep running into this reoccurring problem, my code does not seem to run as I have "undeclared identifiers." I have tried renaming them or redefining them but the same errors keep going or more. I am using VS code at the moment and read about maybe it was VScode itself but I get the same errors regardless.
#include <iostream>
#include <stdlib.h>
#include <string>
#include <fstream>
using namespace std;
class bankAccount {
public:
int accountNum;
string accountName;
string accountType;
double accountBalance;
double accountInterest;
double getInterest;
double updateBalance;
bankAccount(){
accountNum = 0;
accountName = "";
accountType = "";
accountBalance = 0.0;
accountInterest = 0.0;
}
void deposit()
{
long amount;
cout << "\n Please enter the amount you would like to deposit: ";
cin >> amount;
accountBalance = accountBalance + amount;
}
void withdraw()
{
long amount;
cout << "Please enter the amount you would like to withdraw: ";
cin >> amount;
if (amount <= accountBalance)
{
accountBalance = accountBalance - amount;
}
else
{
cout << "You do not have sufficient funds" << endl;
}
}
void interest(){
double getInterest;
cout << "Please enter desired interest amount: ";
cin >> getInterest;
}
void update(){
double updateBalance;
updateBalance = accountBalance * getInterest;
accountBalance += updateBalance;
}
void print(){
string print;
cout << "Welcome Back " << accountName << "," << endl;
cout << "\n Account Number: " << accountNum << endl;
cout << "\n Account Type: " << accountType << endl;
cout << "\n Current Balance: " << accountBalance << endl;
cout << "\n Account Interest: " << accountInterest << endl;
}
void openAccount(){
cout << "Enter Account Number: ";
cin >> accountNum;
cout << "Enter Account Holders Name: ";
cin >> accountName;
cout << "Enter Account Type: ";
cin >> accountType;
cout << "Enter Initial Balance: ";
cin >> accountBalance;
cout << "Enter Interest Rate: ";
cin >> accountInterest;
}
};
int main() {
int choice;
do
{
cout << "Please select the following options ";
cout << "\n 1:View Account";
cout << "\n 2: Open Account";
cout << "\n 3: Deposit" ;
cout << "\n 4: Withdraw ";
cout << "\n 5: Update account";
cin >> choice;
switch (choice)
{
case '1':
print ();
break;
case '2':
openAccount();
break;
case '3':
deposit();
break;
case '4':
withdraw();
break;
case '5':
updateBalance();
break;
}
} while (case !=5);
}
suggested creating an instance of class bankAccount somewhere before switch statement and call the functions like, instance_of_bankAccount.functionName();
At end of loop instead of (case !=5) it should be (choice != 5)
The problem with your code is that you do not have any instance of the class bankAccount, which means you try to call the function which actually does not exist. To fix it, you should create an object of the bankAccount type before the loop in which you can select the operation you want to perform:
int main() {
int choice;
bankAccount bankAcc; // this creates the object we need
do ...
And then for every case you wanted to call the function f(), add prefix bankAcc., so it becomes bankAcc.f(). In your code, it would be:
switch (choice) {
case '1':
bankAcc.print();
break;
case '2':
bankAcc.openAccount();
break;
case '3':
bankAcc.deposit();
break;
case '4':
bankAcc.withdraw();
break;
case '5':
bankAcc.updateBalance();
break;
}
Thanks to it, all functions called will know that they belong to bankAcc and they will change properties only of this particular object.
There is also another mistake in your code: did you really mean to use chars in your switch? At the moment cin >> choice reads an int, saves it in choice and then in switch it gets compared with all values corresponding to cases. The problem is that 1 is very different from '1' (which is casted to the value 49), so inputted int will never satisfy conditions from the menu you print.
Also, while (case !=5) should be changed to while (choice != 5).
Related
I've been building a menu driven console in C++, and I'm currently using switch-case as my options, but now I'm stuck in switch case.
Here's the scenario:
SCENARIO
Explanation:
After inputting invalid option in the main menu, it gives an error which prompts the user to re-input their desired option, now my problem is when the user inputs the correct option for the 2nd attempt, it loops back to the main menu instead of redirecting it to the next menu.
My Goal: To go to the 2nd menu directly from the default without redisplaying the main menu.
My Partial Code:
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int choice;
int booknumber;
int booktitle;
int author;
int datepublished;
int e = 0;
void menu();
void inputbook();
void searchbook();
void borrowbook();
void exit();
//CLASS
class Books
{
public:
int booknumber;
string booktitle;
string author;
string datepublished;
Books(const int booknumber, const string booktitle, const string author, const string datepublished) : booknumber(booknumber), booktitle(booktitle), author(author), datepublished(datepublished) {}
};
//MAIN
int main()
{
while (true)
{
cout << endl;
if (e == 1)
{
break;
}
menu ();
}
return 0;
}
//MENU
void menu()
{
cout << "Welcome to DLC Library System\n";
cout << "Final Project in Advance Programming\n\n";
cout << "PROGRAMMER\n";
cout << "ME\n\n";
cout << "====================================\n";
cout << "[1] -------- Input Book ------------\n";
cout << "[2] -------- Search Book -----------\n";
cout << "[3] -------- Borrow Book -----------\n";
cout << "[4] -------- Exit Program ----------\n";
cout << "====================================\n";
cout << "Input your choice (Number Only): ";
cin >> choice;
switch (choice)
{
case 1:
inputbook ();
break;
case 2:
searchbook ();
break;
case 3:
borrowbook ();
break;
case 4:
exit();
break;
default:
while (choice < 1 || choice > 4)
{
cout << "Wrong Option\n";
cout << "Input your choice (Number Only): ";
cin >> choice;
if (choice < 1 || choice > 4)
{
continue;
}
}
}
}
// INPUT BOOK
void inputbook ()
{
int booknumber;
string booktitle;
string author;
string datepublished;
cout << "INPUT NEW BOOK\n\n";
cout << "Book Number: \n";
cin >> booknumber;
cout << "Book Title: \n";
cin >> booktitle;
cout << "Author: \n";
cin >> author;
cout << "Date Publish: \n";
cin >> datepublished;
Books(booknumber,booktitle, author, datepublished);
cout << "====================================\n";
cout << "[1] -------- Try Again? ------------\n";
cout << "[2] -------- Return to Menu --------\n";
cout << "[3] -------- Exit Program ----------\n";
cout << "====================================\n";
cout << "Input your choice (Number Only): ";
cin >> choice;
switch (choice)
{
case 1:
inputbook ();
break;
case 2:
menu ();
break;
case 3:
exit();
default:
cout << "Wrong Option";
}
}
It's a good idea to avoid repeating code. Here, you have a default case that is essentially an input loop, whereas you could have done that input loop at the start. So the way you wrote it, you still need a loop around the whole thing, plus more logic which makes the code harder to read and more bug-prone.
Why not simply:
cout << "====================================\n";
cout << "[1] -------- Input Book ------------\n";
cout << "[2] -------- Search Book -----------\n";
cout << "[3] -------- Borrow Book -----------\n";
cout << "[4] -------- Exit Program ----------\n";
cout << "====================================\n";
int choice;
bool validInput = false;
while (!validInput)
{
cout << "Input your choice (Number Only): ";
if (!(cin >> choice)) {
std::cerr << "Aborted\n";
return;
}
validInput = (choice >= 1 && choice <= 4);
if (!validInput) {
std::cout << "Invalid input\n";
}
}
switch(choice)
{
// ...
}
Now it's up to you to make your input routine more robust if you choose. Notice I've already bailed out of the function if the input fails. That could be from a stream error, but it could also be if the user enters a non-integer value.
You may instead wish to read your input as a string using std::getline and then convert that to an integer with std::stoi or parse the value from a std::istringstream.
Instead
continue;
try calling
inputbook();
so it won't go back.
That's a problem you are facing because you called switch-case again which is "continue". That's why it goes back to the menu when the user inputs the acceptable range of int you just set.
Just modify the code as below, and handle the valid input verification before entering the switch, in this way you can simply mitigate the issue you had!
cin >> choice;
while (choice < 1 || choice > 4)
{
cout << "Wrong Option\n";
cout << "Input your choice (Number Only): ";
cin >> choice;
if (choice < 1 || choice > 4)
{
continue;
}
}
switch (choice)
{
case 1:
inputbook ();
break;
case 2:
searchbook ();
break;
case 3:
borrowbook ();
break;
default:
exit();
break;
}
I am lost again, I know that there is a way to use push_back to add to the vector, but I am at a loss for how I can actually get it to work. What I am trying to do is add 5 students to a vector (Egrades), and with each student gather 3 separate exam scores and attach them to that students name so that I can compute the averages later.
In my code below, I took out the lines in the cases, and only put student 1 to cut down length.
Where am I going wrong? Did I forget to put something in?
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void)
{
// Delcarations
int score1;
int score2;
int score3;
int scores[5];
vector <int> Egrades;
string student1;
string student2;
string student3;
string student4;
string student5;
// array with menu options
string menu[15];
menu[0] = " **************";
menu[1] = " *** MAIN MENU ***";
menu[2] = " **************";
menu[3] = " Please Choose From The Following Options:";
menu[6] = " 1. Add Student:";
menu[8] = " 2. Compute Student Test Score Average:";
menu[10] = " 3. Search A Student Average Test Score:";
menu[12] = " 4. Compute The Average Of The Average Exams:";
menu[14] = " 5. Exit";
char selection;
cout << "\t\t\t Enter Your Selection: ", cin >> selection, cout << endl;
switch (selection)
{
case '1':
system("CLS");
do
{
{
cout << "Student Information Section:\n\n";
// Student 1 Info
cout << "Enter Student 1 Name:\n";
cin >> student1; cout << endl;
cout << "Enter Exam 1 Score: ";
cin >> score1; cout << endl;
cout << "Enter Exam 2 Score: ";
cin >> score2; cout << endl;
cout << "Enter Exam 3 Score: ";
cin >> score3; cout << "\n" << endl;
}
system("pause");
return main();
}
while (cin >> score1, score2, score3);
break;
case '2':
break;
case '3':
break;
case '4':
break;
case '5':
exit(-1);
break;
default: cout << "\n Invalid selection\n\n";
}
return 0;
}
The things that i would like to accomplish is the functions of methods of the applications but getting many errors from the code which i don't completely understand and try to solve but came up with nothing.
#include <conio.h>
#include <stdio.h>
#include <iostream>
using namespace std;
class bank
{
char name [100],add[100],y;
int balance, amount;
public:
void open_account();
void deposite_money();
void withdraw_money();
void display_account();
};
void bank:open_account()
{
cout << "Enter your full name: ";
cin.ignore();
cin.getline(name,100);
cout << "What type of account you want to open savings (s) or current (c)";
cin >> y;
cout << "Enter amount of deposite: ";
cin >> balance;
cout << "Your account is created ";
}
void bank:deposite_money()
{
int a ;
cout << "Enter how much money you want to deposit: ";
cin >> a;
balance += a;
cout << "Your total deposit amount\n ";
}
void bank:display_account()
{
cout << "Enter the name: "<<name<<endl;
cout << "Enter your address: "<<add<<endl;
cout << "Type of account that you open: "<<y<<endl;
cout << "Amount you deposite: "<<balance<<endl;
}
void bank:withdraw_money()
{
cout << "Withdraw: ";
cout << "Enter the amount of withdrawing";
cin >> amount;
balance = balance - amount;
cout << "Now your total amount left is" <<balance;
}
int main()
{
int ch,x,n;
bank obj;
do
{
cout <<"01")open account\n";
cout <<"02")deposite money\n";
cout <<"03")withdraw money\n";
cout <<"04")display account\n";
cout <<"05")Exit\n";
cout << "Please select from the options above";
cin>>ch;
switch(ch)
{
case 1:"01")open account\n";
obj.open_account();
break;
case 2:"02")deposite money\n";
obj.deposite_money();
break;
case 3:"03")withdraw money\n";
obj.withdraw_money();
break;
case 4:"04")display account\n";
obj.display_account();
break;
case 5:
if(ch == 5)
{
cout << "Exit";
}
default:
cout<< "This is not the proper exit please try again";
}
cout << "\ndo you want to select the next step then please press : y\n";
cout << " If you want to exit then press : N";
x=getch();
if(x == 'y' || x == 'Y');
cout<< "Exit";
}
while (x == 'y' || x == 'Y');
getch();
return 0;
}
The errors that i am getting are
error stray '\'
error missing terminating character
error found ':' in nested name specifier
expected ; before ')' token
These are the errors that usually appears on the logs and has repeated a few times in different lines please help me so that i can finish this application i have learned a lot from making it and is looking forward to build more before my school starts Any help and suggestions on what i should do next is appreciated and advices on what i should do next will greatly be welcome for me to learn from this experience
Im using c++ btw and am trying to build some projects any advice for next time? How can improve myself after this errors and what should i next practice on like a next project that you guys would suggest me
See here:
#include <stdio.h>
#include <iostream>
using namespace std;
class bank
{
char name [100],add[100],y;
int balance, amount;
public:
void open_account();
void deposite_money();
void withdraw_money();
void display_account();
};
void bank::open_account()//: missing
{
cout << "Enter your full name: ";
cin.ignore();
cin.getline(name,100);
cout << "What type of account you want to open savings (s) or current (c)";
cin >> y;
cout << "Enter amount of deposite: ";
cin >> balance;
cout << "Your account is created ";
}
void bank::deposite_money()//: missing
{
int a ;
cout << "Enter how much money you want to deposit: ";
cin >> a;
balance += a;
cout << "Your total deposit amount\n ";
}
void bank::display_account()//: missing
{
cout << "Enter the name: "<<name<<endl;
cout << "Enter your address: "<<add<<endl;
cout << "Type of account that you open: "<<y<<endl;
cout << "Amount you deposite: "<<balance<<endl;
}
void bank::withdraw_money()//: missing
{
cout << "Withdraw: ";
cout << "Enter the amount of withdrawing";
cin >> amount;
balance = balance - amount;
cout << "Now your total amount left is" <<balance;
}
int main()
{
int ch,x,n;
bank obj;
do
{
cout <<"01)open account\n";//Delete " after Number
cout <<"02)deposite money\n";
cout <<"03)withdraw money\n";
cout <<"04)display account\n";
cout <<"05)Exit\n";
cout << "Please select from the options above";
cin>>ch;
switch(ch)
{
case 1:"01)open account\n";//Delete " after Number
obj.open_account();
break;
case 2:"02)deposite money\n";
obj.deposite_money();
break;
case 3:"03)withdraw money\n";
obj.withdraw_money();
break;
case 4:"04)display account\n";
obj.display_account();
break;
case 5:
if(ch == 5)
{
cout << "Exit";
}
default:
cout<< "This is not the proper exit please try again";
}
cout << "\ndo you want to select the next step then please press : y\n";
cout << " If you want to exit then press : N";
cin >> x;
if(x == 'y' || x == 'Y');
cout<< "Exit";
}
while (x == 'y' || x == 'Y');
}
Also don't use using namespace in headers, and in overall learn a better style. This is 80s C with C++ mixed in. Use containers not built in arrays, use iostream and overall get a good C++ book.
Hello I've been working on a C++ banking application that should be able to hold more than one account with all the related field's. I have come across a few issues:
When displaying account info in Display or ShowInfo functions, the first letter of the first name and the middle initial wont show up.
When creating an account only the most recent account is able to be searched for and displayed in display data. I know that an array is needed for this to be possible, I'm just not sure if implemented this correctly.
Thanks for the help. Any input is appreciated!
#include <stdlib.h>
#include <conio.h>
#include <iostream>
#include <string>
using namespace std;
class BankAccount{
double Balance = 0.0;
char ans;
public:struct Name{
char Last_Name[50];
char First_Name[50];
char Middle_Initial[5];
}Name;
public:struct Account{
char Type[1];
int Account_Number;
}Account;
public:
void CreateAccount();
void Withdraw();
void Deposit();
void Display();
void ShowInfo();
int Menu();
};
void BankAccount::CreateAccount(){
do
{
cout << "\nEnter account number: ";
cin >> Account.Account_Number;
cout << "\nEnter the last name for the account: ";
cin.ignore();
cin.getline(Name.Last_Name, 50);
cout << "\nEnter the first name for the account: ";
cin.ignore();
cin.getline(Name.First_Name, 50);
cout << "\nEnter the Middle initial for the account: ";
cin.ignore();
cin.getline(Name.Middle_Initial, 5);
cout << "\nEnter the type of account (C/S) : ";
cin >> Account.Type;
cout << "\nEnter the initial balance of the account: ";
cin >> Balance;
cout << "\n\nAccount Created.";
cout << "\n\nCreate new account? (Y/N) : ";
cin >> ans;
while (ans != 'Y' && ans != 'N'){
cout << "Invalid input. Create new account? (Y/N) : ";
cin >> ans;
}
cout << endl;
} while (ans != 'N');
};
void BankAccount::Withdraw(){
int actNum;
double amount;
cout << "Enter the account number for the account that you wish to withdraw funds: ";
cin >> actNum;
if (actNum == Account.Account_Number){
cout << "Enter the amount you would like to withdraw: ";
cin >> amount;
Balance = Balance - amount;
}
else if (actNum != Account.Account_Number){
cout << "No account found under that number! Try again!";
}
}
void BankAccount::Deposit(){
int actNum;
double amount;
cout << "Enter the account number for the account that you wish to deposit funds: ";
cin >> actNum;
if (actNum == Account.Account_Number){
cout << "Enter the amount you would like to deposit: ";
cin >> amount;
Balance = Balance + amount;
}
else if (actNum != Account.Account_Number){
cout << "No account found under that number! Try again!";
}
}
void BankAccount::Display(){
int actNum;
cout << "Enter the account number for the account that you wish to display account information for: ";
cin >> actNum;
if (actNum == Account.Account_Number){
cout << "Account details for " << Name.First_Name << " " << Name.Middle_Initial << " " << Name.Last_Name << "'s account: " << endl;
cout << "Account Number: " << Account.Account_Number << endl;
cout << "Account Type (Checking / Savings): " << Account.Type << endl;
cout << "Account Balance: $" << Balance << endl;
}
else if (actNum != Account.Account_Number){
cout << "No account found under that number! Try again!";
}
}
void BankAccount::ShowInfo(){
cout << "Account details for " << Name.First_Name << " " << Name.Middle_Initial << " " << Name.Last_Name << "'s account: " << endl;
cout << "Account Number: " << Account.Account_Number << endl;
cout << "Account Type (Checking / Savings): " << Account.Type << endl;
cout << "Account Balance: $" << Balance << endl;
}
int main(int argc, char *argv){
BankAccount ob;
char ch;
cout << "Welcome to Console Banking Application V 1.0!";
cout << "\nSelect an item from the list below by entering the corresponding letter.";
do{
cout << "\n\n A. Create Account \n B. Withdraw \n C. Deposit \n D. Show Account Details \n\n Q. Exit Application\n\n";
ch = ob.Menu();
switch (ch){
case 'A':
case 'a': ob.CreateAccount();
ob.ShowInfo();
break;
case 'B':
case 'b': ob.Withdraw();
break;
case 'C':
case 'c': ob.Deposit();
break;
case 'D':
case 'd': ob.Display();
break;
case 'Q':
case 'q': ob.ShowInfo();
exit(1);
break;
}
} while (1);
}
int BankAccount::Menu(){
char ch;
cout << "Select an option: ";
cin >> ch;
return ch;
}
The simple answer is: You only have one bank account.
If you look at your main function, you create one, and only one BankAccount. As you would probably guess, one BankAccount cannot be used to represent multiple BankAccounts(SoAs aside).
Therefore, you need an array of BankAccounts. It goes something like this:
BankAccount obs[10];
Now you have 10 BankAccounts, no more. So every time you want to create a new BankAccount, just make sure that you create it on a BankAccount in the array that is not currently in use.
obs[0].CreateAccount();
obs[0].ShowInfo();
obs[0].Deposit();
//Make a new account
obs[1].CreateAccount();
...
To go even further, let's consider the fact that you have 10 BankAccounts, and only 10. This is not very extensive now is it? What's a bank with only 10 accounts available? Probably out of business in due time.
The naive solution would be to just add more. 50, 100, even 1000. But do you really want to go back and update that number every single time? That's way too tedious.
Fortunately, there's a convenient container we can use:
#include <vector>
...
std::vector<BankAccount> obs;
...
This is basically an array that expands itself automatically when required. I will not go into detail on how to use vectors because I am sure that you can easily learn to do so yourself. I will, however, leave you with this link so you know where you can start.
I want to display an interface asking the user whether or not they want to use checkings or savings account, and then when they choose bring them to my generic display menu. But I'm not quite sure how to set it up. I was told to make Account objects and use a pointer, but as you can see I'm stuck. If anyone could give me any insight on how I would do this, I would greatly appreciate it.
Here is my code:
#ifndef ACCOUNT_H
#define ACCOUNT_H
class Account
{
private:
double balance; // Account balance
double interestRate; // Interest rate for the period
double interest; // Interest earned for the period
int transactions; // Number of transactions
public:
Account(double iRate = 0.045, double bal = 0)
{ balance = bal;
interestRate = iRate;
interest = 0;
transactions = 0; }
void setInterestRate(double iRate)
{ interestRate = iRate; }
void makeDeposit(double amount)
{ balance += amount; transactions++; }
bool withdraw(double amount); // Defined in Account.cpp
void calcInterest()
{ interest = balance * interestRate; balance += interest; }
double getInterestRate() const
{ return interestRate; }
double getBalance() const
{ return balance; }
double getInterest() const
{ return interest; }
int getTransactions() const
{ return transactions; }
};
#endif
int main()
{
Account Savings;
Account Checkings;
Account *ptr;
Account savings; // Savings account object
char choice; // Menu selection
// Set numeric output formatting.
cout << fixed << showpoint << setprecision(2);
do
{
// Display the menu and get a valid selection.
displayMenu();
cin >> choice;
while (toupper(choice) < 'A' || toupper(choice) > 'G')
{
cout << "Please make a choice in the range " << "of A through G:";
cin >> choice;
}
// Process the user's menu selection.
switch(choice)
{
case 'a':
case 'A': cout << "The current balance is $";
cout << savings.getBalance() << endl;
break;
case 'b':
case 'B': cout << "There have been ";
cout << savings.getTransactions() << " transactions.\n";
break;
case 'c':
case 'C': cout << "Interest earned for this period: $";
cout << savings.getInterest() << endl;
break;
case 'd':
case 'D': makeDeposit(savings);
break;
case 'e':
case 'E': withdraw(savings);
break;
case 'f':
case 'F': savings.calcInterest();
cout << "Interest added.\n";
}
} while (toupper(choice) != 'G');
return 0;
}
void displayMenu()
{
cout << "\n Welcome to The Bank \n";
cout << "-----------------------------------------\n";
cout << "A) Display the account balance\n";
cout << "B) Display the number of transactions\n";
cout << "C) Display interest earned for this period\n";
cout << "D) Make a deposit\n";
cout << "E) Make a withdrawal\n";
cout << "F) Add interest for this period\n";
cout << "G) Exit the program\n\n";
cout << "Enter your choice: ";
}
void makeDeposit(Account *acct)
{
double dollars;
cout << "Enter the amount of the deposit: ";
cin >> dollars;
cin.ignore();
acct.makeDeposit(dollars);
}
void withdraw(Account *acct)
{
double dollars;
cout << "Enter the amount of the withdrawal: ";
cin >> dollars;
cin.ignore();
if (!acct.withdraw(dollars))
cout << "ERROR: Withdrawal amount too large.\n\n";
}
Try something like this:
char displayAccountSelectionMenu();
char displayAccountActionMenu();
void makeDeposit(Account *acct);
void withdraw(Account *acct);
int main()
{
Account Savings;
Account Checkings;
Account *acct = NULL;
char choice; // Menu selection
do
{
// Display the menu and get a valid selection.
choice = displayAccountSelectionMenu();
// Process the user's menu selection.
switch (choice)
{
case 'A':
acct = &Savings;
break;
case 'B':
acct = &Checkings;
break;
case 'C':
return 0;
}
// Set numeric output formatting.
cout << fixed << showpoint << setprecision(2);
do
{
// Display the menu and get a valid selection.
choice = displayAccountActionMenu();
// Process the user's menu selection.
switch (choice)
{
case 'A':
cout << "The current balance is $"
<< acct->getBalance() << endl;
break;
case 'B':
cout << "There have been "
<< acct->getTransactions()
<< " transactions." << endl;
break;
case 'C':
cout << "Interest earned for this period: $"
<< acct->getInterest() << endl;
break;
case 'D':
makeDeposit(acct);
break;
case 'E':
withdraw(acct);
break;
case 'F':
acct->calcInterest();
cout << "Interest added." << endl;
break;
case 'G':
break;
case 'H':
return 0;
}
}
while (choice != 'G');
}
while (true);
return 0;
}
char displayAccountSelectionMenu()
{
char choice;
cout << "\n Welcome to The Bank \n";
cout << "-----------------------------------------\n";
cout << "Select an account:\n";
cout << "A) Savings\n";
cout << "B) Checking\n";
cout << "C) Exit the program\n\n";
cout << "Enter your choice: ";
cin >> choice;
choice = toupper(choice);
while ((choice < 'A') || (choice > 'C'))
{
cout << "Please make a choice in the range of A through C:";
cin >> choice;
choice = toupper(choice);
}
return choice;
}
char displayAccountActionMenu()
{
char choice;
cout << "\n Welcome to The Bank \n";
cout << "-----------------------------------------\n";
cout << "Select an action:\n";
cout << "A) Display the account balance\n";
cout << "B) Display the number of transactions\n";
cout << "C) Display interest earned for this period\n";
cout << "D) Make a deposit\n";
cout << "E) Make a withdrawal\n";
cout << "F) Add interest for this period\n";
cout << "G) Select a different account\n";
cout << "H) Exit the program\n\n";
cout << "Enter your choice: ";
cin >> choice;
choice = toupper(choice);
while ((choice < 'A') || (choice > 'H'))
{
cout << "Please make a choice in the range of A through H:";
cin >> choice;
choice = toupper(choice);
}
return choice;
}
void makeDeposit(Account *acct)
{
//...
}
void withdraw(Account *acct)
{
// ...
}