Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <fstream>
- #include <string>
- using namespace std;
- void title();
- string username,password;
- string Username=username;
- string Password=password;
- void login()
- {
- string username,password;
- string newusername, newpassword;
- char respond;
- cout << "Do you have an account? Y/Nn";
- cin >> respond;
- if (respond == 'Y'|| respond == 'y'){
- ifstream inFile;
- inFile.open("newuser.txt");
- if (inFile.fail()){
- cerr << "Error! x_xnPlease reopen this program." << endl;
- system("PAUSE");
- exit(1);
- }
- cout << "Please enter your username: ";
- cin >> username;
- cout << "nPlease enter your password: ";
- cin >> password;
- string vusername,vpassword;
- while(!inFile.eof()){
- inFile >> vusername >> vpassword;
- if (vusername==username && vpassword==password){
- cout << "Login Successfully!" << endl;
- }else{
- cout << "Fail to login...Please reopen this program." << endl;
- system("PAUSE");
- exit(1);
- }
- }
- }
- else if (respond == 'N'|| respond == 'n'){
- cout << "Please enter your desired username:";
- cin >> newusername;
- cout << "nPlease enter your desired password:";
- cin >> newpassword;
- ofstream outFile;
- outFile.open("newuser.txt");
- outFile << newusername << " " << newpassword << endl;
- outFile.close();
- cout << "n******************************************";
- cout << "nnPlease enter your username: ";
- cin >> username;
- cout << "nPlease enter your password: ";
- cin >> password;
- ifstream inFile;
- inFile.open("newuser.txt");
- if (inFile.fail()){
- cerr << "Error! x_xnPlease reopen this program." << endl;
- system("PAUSE");
- exit(1);
- }
- string vusername1,vpassword1;
- while(!inFile.eof()){
- inFile >> vusername1 >> vpassword1;
- if (vusername1==username && vpassword1==password){
- cout << "Login Successfully!" << endl;
- username += ".txt";
- ofstream createFile;
- createFile.open(username.c_str(),ios::app);
- createFile << username << "n" << "Balance: n";
- }else{
- cout << "Fail to login...Please reopen this program." << endl;
- system("PAUSE");
- exit(1);
- }
- }
- }
- }
- void title()
- {
- cout << "This is a bank system. Enjoy! :)" << endl;
- cout << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^nnn";
- cout << " _________________________________________n";
- cout << " | WELCOME TO YOUR PERSONAL BANK ACCOUNT!|" << endl;
- cout << " |_____________________________________|nnn";
- }
- void functions()
- {
- int choice;
- cout << " ***************************" << endl;
- cout << " 1. Account Information" << endl;
- cout << " 2. Manage Your Money" << endl;
- cout << " 3. Investments" << endl;
- cout << " 4. Loans" << endl;
- cout << " 5. Delete Account" << endl;
- cout << " ***************************" << endl;
- cout << " Please enter your choice: ";
- cin >> choice;
- switch(choice)
- {
- case 1:
- ifstream inFile;
- string name;
- cout << "Please enter your username: ";
- // getline(cin,name);
- //name += ".txt";
- //inFile.open(name.c_str());
- while(getline(cin,name)){
- name += ".txt";
- inFile.open(name.c_str());
- }
- if(inFile.fail()){
- cerr << "Error Opening File" << endl;
- system("PAUSE");
- exit(1);
- }
- string info;
- int line = 0;
- while(!inFile.eof()){
- inFile >> info;
- line++;
- }
- break;
- }
- }
- int main()
- {
- login();
- title();
- functions();
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement