-
ATM program for C++
Im building this atm program where you can enter a user name and password and be able to access your account. I am not to sure if I want to run a header file to store all the ID and passwords or sould I make a 2 dimention array? this program works as is right now but has broke links so you wont be able to see a balance or whatnot. any hints as to running a seperate file which will hold the passwords and ID's?
# include <iostream>
# include <fstream>
# include <string>
# include <algorithm>
using namespace std;
// ****************************** START *************************************
int main()
{
// ***************************** Variables **********************************
float Cbal=0.00;
float Sbal=0.00;
float acc1;
float acc2;
string a;
string bal;
string ID;
string password;
// ****************************** ID SCREEN *********************************
cout << "Welcome to InfantryGhost ATM." << endl;
cout << "Fees for useing this ATM is $0.00" << endl;
cout << "Enter your User ID: ";
cin >> ID;
system("cls");
if (ID =="Garrett") // the ID anything else entered will result in error.
{
// **************************** PASSWORD SCREEN ******************************
cout << "Please enter your Password: ";
cin >> password;
system("cls");
}
else
{
cout << "**ERROR**" << endl; // Error message 2 caused by wrong user ID
return 0;
}
if (password =="gm3475") // password same as ID if anything else ERROR.
{
// ***************************** WELCOME SCREEN *****************************
cout << "****** Welcome " << ID << "*********" << endl;
cout << endl;
cout << "1 for Deposit" << endl;
cout << "2 for Withdrawl" << endl;
cout << "3 for Balance" << endl;
cout << "4 to Exit" << endl;
cout << "# ";
cin >> a;
system("cls");
// ***************************** DEPOSIT SCREEN *****************************
if (a =="1")
{
cout << "****** DEPOSIT SCREEN ********" << endl;
cout << endl;
cout << "1. for Checking" << endl;
cout << "2. for Savings " << endl;
cin >> acc1;
system("cls");
// use this to refer to a file to retreive information
}
else
// ***************************** WITHDRAWL SCREEN ***************************
if (a =="2")
{
cout << "******* WITHDRAWL SCREEN *******" << endl;
cout << endl;
cout << "1- for Checking" << endl;
cout << "2- for Savings" << endl;
cin >> acc2;
system("cls");
// use this to refer to a file to retreive information.
}
else
// ***************************** BALANCE SCREEN *****************************
if (a =="3")
{
cout << "***** BALANCE SCREEN******" << endl;
cout << endl;
cout << "1 for Checking Balance" << endl;
cout << "2 for Savings Balance" << endl;
cin >> bal;
system("cls");
// ********** CHECKING BALANCE *********
if (bal =="1")
{
cout << "Your current balance is $" << Cbal << endl;
return 0;
}
else
//******** SAVINGS BALANCE *********
if (bal =="2")
//run a file here to add and or subtract from the balance
{
cout << "Your current Balance is $" << Sbal << endl;
return 0;
}
// ******* BALANCE ERROR ***********
else
{
cout << "*****ERROR*****" << endl;
return 0;
}
}
else
{
// ***************************** EXIT SCREEN ********************************
cout << "***EXIT***" << endl;
return 0;
}
}
else
{
// ***************************** PASSWORD ERROR *****************************
cout << "****ERROR****" << endl;
return 0;
}
// ***************************** THE END ************************************
system("cls");
return 0;
}
// ***** Built by InfantryGhost *****
why doesnt this show up on the main page?
-
Ok, is this a project for a class or just something you are doing for fun? The reason I ask is because I have written something similar to this. If this is an assignment then tell me exactly what it asks. I guess either way I can send you the code. Correct me if I am wrong but I seem to remember you are not using Visual C++.....are you using Borland? There might be a few things you will need to change but I'll be happy to send you my code. Let me know...I need time to comment it out (I'm lazy that way :) ).
-
the main body can not contain the process of retreveing the files or password the class must do that. next the password id and balance must be stored in a txt or dat file.