# Bank Project Problem

Show 50 post(s) from this thread on one page
Page 1 of 2 12 Last
• October 16th, 2012, 09:15 AM
gaby32
Bank Project Problem
Code:

```// Title: Bank Account Program // Author: // Descripition: A bank account program that lets the user open an account by adding a // customer name then adding a balance to the account, also lets you make a withdrawl from // the account and add a deposit to the account and the user can add interest to the account // which is calculated at 1.67% and the account number used to setup the account is 00112280 #include "stdafx.h" #include <iostream> #include <string> #include <iomanip> // setprecision() funcion #include <conio.h> // _getch() function #include <ctime> // add system time and date using namespace std; const float interest = 1.67; const int account_number = 112280; string customer_first_name, customer_surname; double balance, deposit, withdrawl; int account_exists = 0; int cust_account_number; char dat[10], tim[9]; void display_main_menu(); void open_account(); void account_withdrawl(); void account_deposit(); void add_interest(); void display_account_details(); void exit(); void display_main_menu() {         int choice;         do         {                         system ("cls");                         _strdate(dat);                         _strtime(tim);                                 cout << endl << "Todays date is: " << dat << " and the time is " << tim << endl << endl;                         cout << "\t  Bank Account Menu" << endl;                         cout << "\t_________________________" <<endl << endl;                         cout << "\t1.  Open an account " << endl                                 <<"\t2.  Make a withdrawl " << endl                                 <<"\t3. Make a deposit " << endl                                 <<"\t4. Add interest " << endl                                 <<"\t5.  Exit " << endl << endl                                 <<"Enter Choice: ";                         cin >> choice;                         system ("cls");         switch(choice)         {         case 1: open_account();         break;         case 2: account_withdrawl();         break;         case 3: account_deposit();         break;         case 4: add_interest();         break;         case 5: exit();         cout << "\t Exit main menu" << endl << endl;         break; }// End of display main menu                 } // End of switch statement                 } // End of loop void open_account() // allocate account number, get initial balance and confirmation message that account has been // created {                cout << "Enter customer first name: ";         cin >> customer_first_name;         cout << "Enter customer surname: ";         cin >> customer_surname;         cust_account_number = cust_account_number + 1;         cout << endl << "Enter initial balance: ";         cin >> balance;         cout << endl << "Congratulations on opening your new bank account with us" << endl << endl;         account_exists = 1;                 display_account_details();         cout << endl << endl << "Please press any key to return to the main menu" << endl << endl;         _getch(); } void account_withdrawl() { // if account exists prompt user for withdrawal amount if sufficient funds to withdraw cash // or else print account does not exist message if (account_exists == 1) {         cout << endl << "Enter how much you wish to withdraw: ";         cin >> withdrawl;         if (withdrawl > balance)         cout << "You have insufficient funds in your bank account to cover this withdrawl!"         << endl;         else                 {                 balance = balance - withdrawl;                 cout << endl << (char)156 << withdrawl << " has been withdrawn from your account. " << endl;                 display_account_details();                 }         } //End of first 'if' statement.         else                 cout << "Account does not exist!" << endl << "Press any key to return to the main menu. " << endl;         _getch(); } void account_deposit() { /*if account exists prompt for deposit amount, add deposit to balance else print account does not exist message end if */ if (account_exists == 1) {         cout << "Please enter the amount you wish to deposit: ";         cin >> deposit;         balance + balance + deposit;         display_account_details(); }// End of True "if" statement else         cout << "Account does not exist!" <<endl << "Press any key to return to the main menu." << endl;         _getch(); } void add_interest() {         float interest_added = 0;         if (account_exists == 1)                 {                         interest_added = balance * (interest/100);                         cout << (char) 156 << fixed << setprecision(2) << interest_added << "has been added to the following account." << endl << endl;                         balance = balance + interest_added;                         display_account_details();                 } // End of true 'if' statements else                 cout << "Account does not exist!" << endl << "Press any key to return to the main menu. " << endl;                 _getch() } void display_account_details() {         cout << "\t Account Details" << endl << endl;         cout << "\t Customer Name:  " << customer_first_name << " " << customer_surname << endl;         cout << "\t Account Number: " << "00" << account_number << endl;         cout << "\t Current Balance: " << (char)156 << fixed << setprecision(2)                 << balance << endl; //(char)156 inserts the symbol '£'. } void main() (         display_main_menu(); }```
Hi

I have a few problems on the code for the bank account project, it will be appreciated if you can have a look for me:

Problem 1:

#include "stdafx.h"
In c++ the word include in the above line is highlighted in red.

Problem 2:

} // End of switch statement

} // End of loop

void open_account()// allocate account number, get initial balance and confirmation message that account has been
// created

{

In c++ the bracket next to // End of loop is highlighted in red.

Problem 3:

_getch()

}

void display_account_details()

In c++ the bracket above void display_account_details is highlighted in red.

Problem 4:

void main()
}
}

In c++ the both the opening and closing bracket is highlighted in red and also the ; after display_main_menu();

Thanks
• October 16th, 2012, 09:28 AM
GCDEF
Re: Bank Project Problem
Do requires a matching while

balance + balance + deposit; should be balance = balance + deposit;
• October 16th, 2012, 01:35 PM
gaby32
Re: Bank Project Problem
hello

Thanks i got that: balance = balance + deposit;

but I'm still having the above 4 problems in my first post
• October 16th, 2012, 02:02 PM
GCDEF
Re: Bank Project Problem
Quote:

Originally Posted by gaby32
hello

Thanks i got that: balance = balance + deposit;

but I'm still having the above 4 problems in my first post

Did you understand what I meant when I said do requires a matching while? The others are really pretty self-explanatory. Also, look very closely at your main function. Look at what is really there, not what you think is there.
• October 16th, 2012, 02:04 PM
gaby32
Re: Bank Project Problem

void main()
{
}
• October 16th, 2012, 02:13 PM
gaby32
Re: Bank Project Problem
update problem 3 sorted added ; at end of getch() so it becomes getch();
• October 16th, 2012, 02:17 PM
GCDEF
Re: Bank Project Problem
Quote:

Originally Posted by gaby32

void main()
{
}

Also, while some compiler will accept void main(), they shouldn't. It's illegal syntax. main must return an int. You'd be better off getting into that habit so your code will still work on conforming compilers.
• October 16th, 2012, 02:35 PM
gaby32
Re: Bank Project Problem
thanks for that tip.

but why is #include "stdafx.h" highlighted in red?
• October 16th, 2012, 02:43 PM
GCDEF
Re: Bank Project Problem
What compiler are you using that highlights things in red? Does that file exist? Just delete the #include statement. You don't need it for your app anyway.
• October 16th, 2012, 02:48 PM
gaby32
Re: Bank Project Problem
ms v studio 2008 express edition
• October 16th, 2012, 02:49 PM
gaby32
Re: Bank Project Problem
closing bracket for problem 2 still presets, can't see any silliy mistakes

• October 16th, 2012, 02:50 PM
GCDEF
Re: Bank Project Problem
Quote:

Originally Posted by gaby32
closing bracket for problem 2 still presets, can't see any silliy mistakes

I've already told you twice what the problem is.
• October 16th, 2012, 02:54 PM
gaby32
Re: Bank Project Problem
Code:

```#include <iostream> #include <string> #include <iomanip> // setprecision() funcion #include <conio.h> // _getch() function #include <ctime> // add system time and date using namespace std; const float interest = 1.67; const int cust_account_number = 112280; string customer_first_name, customer_surname; double balance, deposit, withdrawl; int account_exists = 0; int account_number; char dat[10], tim[9]; void display_main_menu(); void open_account(); void account_withdrawl(); void account_deposit(); void add_interest(); void display_account_details(); void exit(); void display_main_menu() {         int choice;         do         {                         system ("cls");                         _strdate(dat);                         _strtime(tim);                                 cout << endl << "Todays date is: " << dat << " and the time is " << tim << endl << endl;                         cout << "\t  Bank Account Menu" << endl;                         cout << "\t_________________________" <<endl << endl;                         cout << "\t1.  Open an account" << endl                                 <<"\t2.  Make a withdrawl" << endl                                 <<"\t3. Make a deposit" << endl                                 <<"\t4. Add interest" << endl                                 <<"\t5.  Exit" << endl << endl                                 <<"Enter Choice: ";                                                 cin >> choice;                                                 system ("cls");         switch(choice)         {         case 1:                 open_account();         break;         case 2:                 account_withdrawl();         break;         case 3:                 account_deposit();         break;         case 4:                 add_interest();         break;         case 5:                 exit();                 cout << "\t Exit main menu" << endl << endl;         break;         }// End of switch statement                 } // End of loop         } //End of 'display_main_menu' method void open_account() // allocate account number, get initial balance and confirmation message that account has been // created {                cout << "Enter customer first name: ";         cin >> customer_first_name;         cout << "Enter customer surname: ";         cin >> customer_surname;         account_number = account_number + 1;         cout << endl << "Enter initial balance: ";         cin >> balance;         cout << endl << "Congratulations on opening your new bank account with us" << endl << endl;         account_exists = 1;                 display_account_details();         cout << endl << endl << "Please press any key to return to the main menu" << endl << endl;         _getch(); } void account_withdrawl() { // if account exists prompt user for withdrawal amount if sufficient funds to withdraw cash // or else print account does not exist message if (account_exists == 1) {         cout << endl << "Enter how much you wish to withdraw: ";         cin >> withdrawl;         if (withdrawl > balance)         cout << "You have insufficient funds in your bank account to cover this withdrawl!"         << endl;         else                 {                 balance = balance - withdrawl;                 cout << endl << (char)156 << withdrawl << " has been withdrawn from your account. " << endl;                 display_account_details();                 }         } //End of first 'if' statement.         else                 cout << "Account does not exist!" << endl << "Press any key to return to the main menu. " << endl;         _getch(); } void account_deposit() { /*if account exists prompt for deposit amount, add deposit to balance else print account does not exist message end if */ if (account_exists == 1) {         cout << "Please enter the amount you wish to deposit: ";         cin >> deposit;         balance = balance + deposit;         display_account_details(); }// End of True "if" statement else         cout << "Account does not exist!" <<endl << "Press any key to return to the main menu." << endl;         _getch(); } void add_interest() {         float interest_added = 0;         if (account_exists == 1)                 {                         interest_added = balance * (interest/100);                         cout << (char) 156 << fixed << setprecision(2) << interest_added << "has been added to the following account." << endl << endl;                         balance = balance + interest_added;                         display_account_details();                 } // End of true 'if' statements else                 cout << "Account does not exist!" << endl << "Press any key to return to the main menu. " << endl;                 _getch(); } void display_account_details() {         cout << "\t Account Details" << endl << endl;         cout << "\t Customer Name:  " << customer_first_name << " " << customer_surname << endl;         cout << "\t Account Number: " << "00" << account_number << endl;         cout << "\t Current Balance: " << (char)156 << fixed << setprecision(2)                 << balance << endl; //(char)156 inserts the symbol '£'. } int main() { display_main_menu(); }```
updated code
• October 16th, 2012, 02:57 PM
GCDEF
Re: Bank Project Problem
As I said, I've already told you the problem twice in this thread.
• October 16th, 2012, 03:39 PM
gaby32
Re: Bank Project Problem

}// End of switch statement

} // End of loop
while(choice !=5);