#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
string name;
int exit = 8;
int funds;
int oneortwo;
int deposit;
int currentbalance = 100;
int withdrawl;
int wagain;
cout<< "Hello please enter your name to get to your bank information...\n";
cin >> name ;
start:
cout << "Thank you "<< name<< " you have " <<currentbalance<<"$ in your bank, would you like to Deposit(1)\n or Withdrawl(2) funds?" <<endl;
cout << "Please select 1 or 2.\n" ;
cin >> oneortwo;
if (oneortwo == 1)
{
do
{
int dagain;
cout << "You have choosen Deposit, how much would you like to deposit? \n" ;
cin >> deposit;
currentbalance = currentbalance + deposit;
cout << "Your balance is now $" <<currentbalance << endl;
cout << "Press 1 to make another depsoit or press 9 to quit. "<<"\n";
cin >>dagain;
if (dagain == 9)
exit = exit +1;
else
exit = exit;
} while (exit < 9);
}
else
if (oneortwo ==2);
do
{
cout << "You have choosen Withdrawl, how much would you like to withdrawl?\n";
cin >>withdrawl;
currentbalance = currentbalance - withdrawl;
if( currentbalance <=0 )
{
currentbalance = currentbalance + withdrawl;
cout <<"You do not have enough money to make this withdrawl, your current balance is "<<currentbalance<<"\n";
goto start;
}
cout << "Your balance is now $" <<currentbalance <<endl;
cout <<" Press 1 to make another withdrawl or press 9 to quit. "<<"\n";
cin >> wagain;
if (wagain == 9)
exit = exit +1;
else
exit = exit;
}while (exit < 9);
return 0;
}
C++ bank program
Hi Here is my current working code, im pretty happy with it, I would just like to clean it up and make a few chanes
I am thinking of trying to use some functions to clean this up, might make it a little nicer also looking for a way if the user presses 9 any time during the app to shut the program down trying to work at making my menu work smoother.
You have
two places in your code.
If im not very wrong you can remove both without realy changing anything.
It doesnt matter if the program enters this else or not since it doesnt do anything.
You also have
Are you sure you want to have that semi-colon at the end?
It will end the if immidiately, so whatever comes after this line is not part of the if
...else exit = exit;...
two places in your code.
If im not very wrong you can remove both without realy changing anything.
It doesnt matter if the program enters this else or not since it doesnt do anything.
You also have
else if (oneortwo ==2);
Are you sure you want to have that semi-colon at the end?
It will end the if immidiately, so whatever comes after this line is not part of the if
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement