MenuBuilder: wont show the menu selection

Not understanding why the choice entered in the testMenus1 will not run through the switch statement in the choseMenu() function located in menuBuilder1.cpp. I am using classes for the first time so any help or hint on what I am missing will be very much appreciated.

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
testMenu.cpp
#include <iostream>
#include "MenuBuilder1.h"
using namespace std;
int main()
{
	MenuBuilder1 transaction;
	int choice = 0;
	while(choice !=7)
	{
		transaction.buildMenu();
		cin>>choice;
		transaction.choseMenu(choice);
	}
	return 0;
}

MenuBuilder1.cpp


#include <iostream>
#include "MenuBuilder1.h"
using namespace std;
MenuBuilder1::MenuBuilder1()
{
	double balance= 2439.45 ;
}
bool exitFlag;
int buildMenu()
{
	cout<<"\nWelcome to the DeVry Bank Automated Teller Machine\n";
	cout<<"1)   Check balance\n";
	cout<<"2)   Make withdraw\n";
	cout<<"3)   Make deposit\n";
	cout<<"4)   View account information\n";
	cout<<"5)   View Statement\n";
	cout<<"6)   View bank information\n";
	cout<<"7)   Exit";
	cout<<endl;
}
void MenuBuilder1::viewStatement()
{
	cout<<"\n\n01/01/11 -McDonalds-$6.27";
        cout<<"01/15/11 - Kwik Trip - $34.93 ";
        cout<<"02/28/11 - Target - $124.21";
}
void MenuBuilder1::viewAcctInfo()
{
	cout<<"\n\nName: MIchael Heitner";;
	cout<<"\nAccount Number: 1234554321";
	
}
void MenuBuilder1::viewBankInfo()
{
	cout<<"Devry Bank, established 2011"<<endl;
	cout<<"(123) 456-7890"<<endl;
	cout<<"12345 1st St."<<endl;
	cout<<"Someplace, NJ 12345"<<endl;
}
double balance;
void MenuBuilder1::displayBalance()
{
  cout<<"\nCurrent balance is:$2439.45 "<<endl;
}
void MenuBuilder1::depositAcct()
{
  double deposit;
  cout<<"\nEnter amount to Deposit :- ";
  cin>>deposit;
  balance = balance + deposit;
}
void MenuBuilder1::withdrawAcct()
{
  double withdraw;
  cout<<"\nHow much would you like to withdraw?";
  cin>>withdraw;
  balance=balance-withdraw;
  
}
int MenuBuilder1::choseMenu(int &choice)
{
	switch(choice)
	{
	case '1':
		displayBalance();
		break;
	case '2' : 
		withdrawAcct();
		break;
	case '3' :
		depositAcct();
		break;
	case '4' :
		viewAcctInfo();
		break;
	case '5':
		viewStatement();
		break;
	case '6' :
		viewBankInfo();
		break;	
	case '7':
		exitFlag=false;
	
	}
	return choice;
}


Header File:
MenuBuilder1.h
#pragma once

class MenuBuilder1
{
public:
	MenuBuilder1();
	int buildMenu();
	void viewStatement();
	void viewAcctInfo();
	void viewBankInfo();
	int choice;
        void displayBalance();
        void depositAcct();
	double deposit;
        void withdrawAcct();
	double withdraw;
	int choseMenu(int &choice);
private:
	double balance;
	

};
Last edited on
Topic archived. No new replies allowed.