Here is a new take... I am getting closer but clearly I still have a lot of issues. Here is my desired output:
Welcome to the DeVry 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: (Student’s 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:
Devry 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.
And here is my current 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
|
#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;
int menu_func(void);
int main(void) {
int menu = 0;
double balance;
double withdraw = 0;
double deposit = 0;
while(menu!=7) {
menu=menu_func();
switch(menu) {
case 1:
srand(time(0));
balance = rand();
cout << "Your balance is $" << balance << "." << endl;
//I don't know how to get it to go back to pick a number on the menu.
case 2:
do
{
cout << "How much would you like to withdraw?";
cin >> withdraw;
if (withdraw<0 || withdraw>balance)
{
cout << "That is an invalid amount." << endl;
}
else
cout << "Thank you, your new balance is $" <<balance - withdraw << ".";
}
while (withdraw<0 || withdraw>balance);
break;
case 3:
cout << "How much would you like to deposit?";
cin >> deposit;
if(deposit > 0)
{
cout << "Thank you, your new balance is $" << balance+ deposit << ".";
}
break;
case 4:
cout << "Name: Beatriz Shimizu";
cout << "Account Number: 1234554321";
break;
case 5:
cout << "01/01/11 - McDonald's\t\t $6.27" << endl;
cout << "01/15/11 - Kwik Trip\t\t $11.11" << endl;
cout << "02/02/11 - Target\t\t $2.17" << endl;
cout << "02/07/11 - In-N-Out\t\t $8.26" << endl;
cout << "02/22/11 - DeVry University\t\t $5,233.00" << endl;
break;
case 6:
cout << "DeVry Bank, established 2011" << endl;
cout << "(123) 456-7890" << endl;
cout << "1234 Takeyourmoney Street" << endl;
cout << "Someplace, CA 12345" << endl;
break;
case 7:
cout << "Thank you for using DeVry Bank Automated Teller Machine.";
break;
default:
cout << "Invalid Selection";
break;
};
}
cout << endl;
system("pause");
return 0;
}
int menu_func(void) {
int menu=0;
cout << "Welcome to the DeVry Bank Automated Teller Machine" << endl
<< "1. Check balance" << endl
<< "2. Make withdrawal" << endl
<< "3. Make deposit" << endl
<< "4. View account information" << endl
<< "5. View statement" << endl
<< "6. View bank information" << endl
<< "7. Exit" << endl;
cout << "Please enter a selection: ";
cin >> menu;
return menu;
}
|
Can anyone point me in the right direction?