This program is very tricky...
First off it's an ATM I coded and every time you as for money back or put money in or ANYTHING it the name and account number gets re-entered.
Here's the code:
#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
float opening_bal = 2000.99; //For points practice (.99)
struct bank
{
public:
void opening();
void menu();
char first_name[201];
char last_name[21];
int accnt_num;
};
int main(int argc, char *argv[])
{
bank Money;
cout<<"Welcome to First National Bank ATM!"<<endl;
cout<<"ATM software developed by: Shaun Dougherty"<<endl;
Money.opening();
Money.menu();
system("PAUSE");
return 0;
}
void bank::opening()
{
char answer[8];
cout<<"Please Enter your first name\n"; cin>>first_name;
cout<<"Enter your last name\n";
cin>>last_name;
cout<<"Hello " << strcat(first_name, last_name) <<"!"<<endl;
cout<<"Please enter your account number\n";
cin>>accnt_num;
}
void bank::menu()
{
float deposit_amnt, withdrawal_amnt;
int choice;
for(;;)
{
cout<<"Welcome, "<<strcat(last_name, first_name)<<endl;
cout<<"Account #:" << accnt_num<<endl;
cout<<"Current Balance: $"<<fixed<<setprecision(2)<<opening_bal<<endl;;
cout<<"-----------------------------------------"<<endl;
cout<<" **********************************"<<endl;
cout<<" * MENU * "<<endl;
cout<<" * 1. Deposit 2. Withdrawal * "<<endl;
cout<<" * 3. Fast Cash ($60) 4. Check Balance *"<<endl;
cout<<" * 0 = exit *"<<endl;
cout<<" ****************************************"<<endl;
cin>>choice;
if ( choice == 0 )
{
break;
}
else
{
{
switch (choice)
{
case 1:
cout<<"Deposit amount?\n";
cin>>deposit_amnt;
opening_bal += deposit_amnt;
cout<<"Your balance is now $" <<setprecision(2)<<fixed<<opening_bal<<endl;
break;
case 2:
cout<<"Withdrawal amount?\n";
cin>> withdrawal_amnt;
if (withdrawal_amnt > opening_bal )
{
cout<<"There is not enough to make the transaction!!!"<< '\a'<<endl;
break;
}
else
{
opening_bal -= withdrawal_amnt;
}
cout<<"Your balance is now $" << setprecision(2)<<fixed<<opening_bal<<endl;
break;
case 3:
opening_bal -= (float) 60.00;
cout<<"$60 cash taken out... Balance is now $"<<setprecision(2)<<fixed<<opening_bal<<endl;
break;
case 4:
cout<<"Your current balance is $"<<setprecision(2)<<fixed<<opening_bal<<endl;
break;
case 0:
break;
default:
cout<<'\a'<< "Invalid Number\n";
break;
}
}
}
system("cls");
}
}
I'm thinking hopefully somebody can run this program see its errors and be able to help me. thanks :-)