this is filling in the input fields after it where i have the passwords at.
Code://This program written by Dan Kemper //This is a bank program //Includes Header Files #include <conio.h> #include <iostream> #include <fstream> #include <iomanip> #include <windows.h> #include <cctype> //Required for cout using namespace std; int main () { //Declares variables char FirstName[20]; //first name char LastName[30]; //last name char Password; // password to get into registered users info char PW; //gets password from dat file to compare char User; //if person is registered or new char Print; //prints to textfile when told to float Balance; //balance when opening account float Deposits; //deposits float Withdrawls; //withdrawls float NewBalance; //balance after withdrawls and deposits are done. number thats saved into textfile for next time opened as 'balance' //Outputs to screen cout << " AAA TTTTTTTTTTTTTTT MMMMM MMMMM\n"; cout << " AAAAA TTTTTTTTTTTTTTT MMMMMM MMMMMM\n"; cout << " AAA AAA TTTTTT MMM MMM MMM MMM\n"; cout << " AAA AAA TTTTTT MMM MMM MMM MMM\n"; cout << " AAAAAAAAAAA TTTTTT MMM MMM MMM MMM\n"; cout << " AAAAAAAAAAAAA TTTTTT MMM MMM MMM MMM\n"; cout << " AAA AAA TTTTTT MMM MMM MMM MMM\n"; cout << "AAA AAA TTTTTT MMM MMMMM MMM\n"; cout << "\nThis is a bank program.\n"; cout<<"\nPress [ENTER] to continue...\n"; cin.get(); system("cls"); cout << "Are you a registered user (A), or would you like to make an account (B)? "; cin.get(User); User = toupper(User); //Makes uppercase automatically system("cls"); if (User=='a' || User=='A') { ifstream infile; //declares file pointer named infile infile.open("passwords.dat",ios::in); //opens dat file which has password in it infile.get(PW); //gets password from file cout << "First Name: "; cin >> FirstName; cout << "\nLast Name: "; cin >> LastName; cout << "\nPassword: "; cin.get(Password); cout << PW; getch(); system("cls"); if (Password==PW) { cout << "Balance: " << Balance; cout << "\n\nDeposits: "; cin >> Deposits; cout << "\n\nWithdrawls: "; cin >> Withdrawls; cout << "\n\nNew Balance: " << NewBalance; cout << "\n\n" << FirstName << " " << LastName << ", is all the above information correct (Y/N)? "; cin >> Print; } if (Password!=PW) { cout << "\n\nThat was the incorrect password!\a\a\a"; getch(); return 0; } infile.close(); } if (User=='b' || User=='B') { cout << "First Name: "; cin >> FirstName; cout << "\nLast Name: "; cin >> LastName; cout << "\nPick Your Password: "; cin.get(Password); cout << "\nDeposits: "; cin >> Deposits; cout << "\nBalance: "; cout << setiosflags (ios::fixed) << setprecision(2) << Deposits ; cout << "\n\n" << FirstName << " " << LastName << ", is all the above information correct (Y/N)? "; cin >> Print; } if (Print=='y' || Print=='Y') { ofstream outfile ("Bank.txt"); outfile << "Name: " << FirstName << " " << LastName; outfile << "\nPassword: *******"; outfile << "\n\nDeposits: " << Deposits; outfile << "\nBalance: " << Deposits; outfile << "\nThank you!"; outfile.close(); ofstream pwfile ("Passwords.dat"); pwfile << Password; pwfile.close(); cout << "\n\nThank You!\a"; } if (Print=='n' || Print=='N') { cout << "Okay well then your going to have to restart, sorry.\a"; cout << "\n\nThank You!\a"; } //Calculation NewBalance = Balance + Deposits - Withdrawls; //Stops program until button is pressed getch(); return 0; }
also i would liek to know if theres a way i can use the persons name (which the enter) to name the outfiles so each new user would have there own files
thanks for the help



LinkBack URL
About LinkBacks


