Why isnt this menu allowing me to make another selection?
Oct 4, 2015 at 5:28pm UTC
It has been a while since I have worked with menu's and I know that I had this sort of thing working before but I can find my code. Please help me figure out what I am missing to allow the user to make another selection after the initial selection.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#include <iostream>
#include <cstdlib>
#include "Assignment2.h"
int MainMenu()
{
//=====Variable declarations
int Choice;
bool quit = false ;
while (!quit)
{
//=====body
cout << "== MAIN MENU ==" << endl;
cout << "1. ADD a customer" << endl;
cout << "2. Print ALL customer data for ALL customers" << endl;
cout << "3. UPDATE existing customer DATA" << endl;
cout << "4. EXIT" << endl;
cout << "Enter a menu choice: " << endl;
cin >> Choice;
cout << endl;
switch (Choice)
{
case 1: CreateAccount(); //replace "Add a customer with CreateAccountNumber Function here
break ;
case 2: cout << "Print All customer DATA" << endl; //replace "Print ALL customer DATA" with PrintCustomerData function here
break ;
case 3: cout << "UPDATE existing customer DATA: " << endl;
cout << "a) Make a Deposit: " << endl;
//(Deposit)
cout << "b) Withdrawal: " << endl;
//(Withdrawal)
cout << "c) Print Account Balance: " << endl;
//(PrintAccountBallance)
cout << "d) Update Account Balance WITH interest: " << endl;
//(UpdateAccountBalance)
cout << "e) Exit to Main Menu" << endl;
//(ExitToMainMenu)
case 4: cout << "EXIT" << endl;
quit = true ;
}
return (Choice);
}//end while
}//end MainMenu
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
#include <cstdlib>
#include "Assignment2.h"
int main()
{
int choice;
cout << "*****Pro-Bank Extreme*****" << endl;
MainMenu();
system ("pause" );
return 0;
}
Oct 4, 2015 at 5:40pm UTC
The return statement on line 47 ends the function.
Another problem is that you have forgot to a break statement at the end of case 3.
Oct 4, 2015 at 5:48pm UTC
Thanks! As usual, its the little things that I miss. Thanks for your help!!
Topic archived. No new replies allowed.