Menu-Driven Application

I'm way out of my league right now!!! I have to code, build and execute an Automated Teller Machine Menu-Driven Console. The output must include the following:

Welcome to the Happy Day Bank Automated Teller Machine!

1. Check balance
2. Make withdrawal
3. Make deposit
4. View account information
5. View statement
6. View bank information
7. Exit


The result of choosing #1 will be the following:
Current balance is: $2439.45

The result of choosing #2 will be the following:
How much would you like to withdraw? $200.50

The result of choosing #3 will be the following:
How much would you like to deposit? $177.32

The result of choosing #4 will be the following:
Name: (First and last name goes here)
Account Number: 1234554321

The result of choosing #5 will be the following:
01/01/11 - McDonald’s - $6.27
01/15/11 - Kwik Trip - $34.93
02/28/11 - Target - $124.21

The result of choosing #6 will be the following:
Happy Day Bank, established 2011
(123) 456-7890
12345 1st St.
Someplace, NJ 12345

The result of choosing #7 will be the following:
*Exit the program - terminate console application.
OP: I suggest you start by googling for C++ ATM code and seeing what you can adapt for your uses and the general way these programs tackle their problems
That's what I've been doing. I think I have some good stuff to work with so far. I'm at work so I can't plug it into VS yet to see where how it looks. I don't want to post my code on here unformatted.
This is what I have so far:

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
#include <iostream>
using namespace std;

int main()

{

double balance = 2439.45;
double withdraw, deposit, accountInfo, statement, bankInfo;
int option;
cout<<"\n";
cout<<" ***  WELCOME!  ***\n";
cout<<"*** Happy Day Bank Automated Teller Machine***"<<endl;
cout<<"Choose a Transaction:\n";
cout<<"\n";
cout<<"[1] Check Balance \n"
<< "[2] Make Withdrawal \n"
<< "[3] Make A Deposit \n"
<< "[4] View Account Information \n"
<< " [5] View Statement \n"
<< " [6] View Bank Information \n"
<< " [7] Exit \n"
<< "\n"
<< "Enter Option:";
cin>>option;

switch(option)
{
case 1:
cout<<"\n[[[BALANCE INQUIRY]]]\n";
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<"\n Your current balance is $"<<balance<<endl;
break;

case 2:
cout<<"\n[[[WITHDRAW]]]\n";
cout<<"Enter amount: $";
cin>>withdraw;

balance = balance - withdraw;

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

cout<<"You withdrew $"<<withdraw<<endl;
cout<<"Your remaining balance is $"<<balance<<endl;
break;

case 3:
cout<<"\n[[[DEPOSIT]]]\n";
cout<<"Enter amount: $";
cin>>deposit;

balance = balance + deposit;

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

cout<<"You deposited $"<<deposit<<endl;
cout<<"Your new balance is $"<<balance<<endl;
break;
case 4:
cout<<"\n[[[ACCOUNT INFORMATION]]]\n";
cout<<"Name: Account Name";
cout<<"Account Number: 1234554321"<<endl;
break;
case 5:
cout<<"\n[[[STATEMENT]]]\n";
cout<<"01/01/11 – Mcdonald’s - $6.27";
cout<<"01/15/11 – Kwik Trip - $34.93";
cout<<"02/28/11 – Target - $124.21"<<endl;
break;
case 6:
cout<<"\n[[[BANK INFORMATION]]]\n";
cout<<"Happy Day Bank, established 2011";
cout<<" (123) 456-7890";
cout<<"12345 1st St. ";
cout<<"Someplace, NJ 12345"<<endl;

case 7:
cout<<"\n***[[[EXIT MODE]]]***\n";

break;


default:
cout<<"\n That is an invalid option \n";
}

}
else


cout<<"Pls try again!!!\n";

}

return 0;
}
Last edited on
What help do you need?

Line 95: The else is not associated with an if statement.

Line 80: case has no break.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.


So should I take the else out? I also added the break, but I'm getting syntax errors on lines 96, 97, 100 and 101. Updated code:

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
#include <iostream>
using namespace std;

int main()

{
    double balance = 2439.45;
    double withdraw, deposit;
    
    int option;
    cout<<"\n";
    cout<<" ***  WELCOME!  ***\n";
    cout<<" *** Happy Day Bank Automated Teller Machine ***"<<endl;
    cout<<"Choose a Transaction: \n";
    cout<<"[1] Check Balance \n"
    <<"[2] Make Withdrawal \n"
    <<"[3] Make A Deposit \n"
    <<"[4] View Account Information \n"
    <<"[5] View Statement \n"
    <<"[6] View Bank Information \n"
    <<"[7] Exit \n"
    <<"\n"
    <<"Enter Option:";
    cin>>option;
    
    switch(option)
    {
        case 1:
        cout<<"\n[[[BALANCE INQUIRY]]]\n";
        cout.setf(ios::fixed);
        cout.setf(ios::showpoint);
        cout.precision(2);
        cout<<"\n Your current balance is $"<<balance<<endl;
        break;
        
        case 2:
        cout<<"\n[[[WITHDRAWAL]]]\n";
        cout<<"Enter Amount: $";
        cin>>withdraw;
        
        balance = balance - withdraw;
        
        cout.setf(ios::fixed);
        cout.setf(ios::showpoint);
        cout.precision(2);
        
        cout<<"You Withdrew $"<<withdraw<<endl;
        cout<<"Your Remaining Balance is $"<<balance<<endl;
        break;
        
        case 3:
        cout<<"\n[[[DEPOSIT]]]\n";
        cout<<"Enter Amount: $";
        cin>>deposit;
        
        balance = balance + deposit;
        
        cout.setf(ios::fixed);
        cout.setf(ios::showpoint);
        cout.precision(2);
        cout<<"You Deposited $"<<deposit<<endl;
        cout<<"Your New Balance is $"<<balance<<endl;
        break;
        
        case 4:
        cout<<"\n[[[ACCOUNT INFORMATION]]]\n";
        cout<<"Name: Student Name";
        cout<<"Account Number: 123454321"<<endl;
        break;
        
        case 5:
        cout<<"\n[[[STATEMENT]]]\n";
        cout<<"01/01/11 - McDonald's - $6.27";
        cout<<"01/15/11 - Kwik Trip - $34.93";
        cout<<"02/28/11 - Target - $124.21"<<endl;
        break;
        
        case 6:
        cout<<"\n[[[BANK INFORMATION]]]\n";
        cout<<"Happy Day Bank, Established 2011";
        cout<<"(123) 456-7890";
        cout<<"12345 1st St.";
        cout<<"Someplace, NJ 12345"<<endl;
        break;
        
        case 7:
        cout<<"\n***[[[EXIT MODE]]]***\n";
        break;
        
        default:
        cout<<"\n INVALID OPTION \n";
    }
        }
    
        
        cout<<"PLEASE TRY AGAIN\n";
    }
        
        return 0;
        }
    }
        
Last edited on
I believe I've figured it out, too many closing brackets.
Hello Turner1981,

Yes the closing braces at the end of main are a problem. Now what you need is a do while and to put the cases into functions.

Hope that helps,

Andy
Where would I put the do while? I'll research and try to figure out how to put the cases into functions.
Hello Turner1981,

I would start with line 11 and put the end of the loop after the closing brace of the switch statement.

Instead of all the cout statements in the cases 1 to 6. Put these statements in a function then in the case part just call the function like:

1
2
3
        case 1:
        BalanceInquiory(balance);
        break;


1
2
3
4
5
6
7
8
void BalanceInquiory(double balance)
{
        cout<<"\n[[[BALANCE INQUIRY]]]\n";
        cout.setf(ios::fixed);
        cout.setf(ios::showpoint);
        cout.precision(2);
        cout<<"\n Your current balance is $"<<balance<<endl;
}


and at the beginning above main you will need void BalanceInquiory(double balance);.

Hope that helps,

Andy
So I have my code working, but I can only input once. After I get the result I want, nothing happens. How do I get it to allow me to input another option?
Hello Turner1981,

Once I cleaned up the extra closing "}" the program worked fine. refer to previous message about the do while loop. http://www.cplusplus.com/forum/beginner/207822/#msg980603

The only part I would change is to put the close of the do while loop after line 96. And you will have to add some code in order to end the while loop. Something like this might work:

1
2
3
4
5
6
if (cont)
{
	cout << "\n ANOTHER TRANSACTION? Y/N ";
	cin >> answer;
}
if (toupper(answer) == 'N') cont = false;


with "cont" defined as a bool and set to true when it was defined. I added this as a fix to work with case 7 in the switch where I also set "cont" to false.

Hope that helps,

Andy
Topic archived. No new replies allowed.