1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
void display(char& anwser);
void N_account(char& anwser,string & name);
void Exist(string& name_search, char& anwser, string name_from_file);
int main()
{
int start_money;
string name, name_search, name_from_file;
char anwser;
display(anwser);
N_account(anwser,name);
Exist(name_search, anwser,name_from_file);
}
void display(char& anwser)
{
cout << setw(65) << "=================" << endl;
cout << setw(65) << "Banking Managment" << endl;
cout << setw(65) << "=================" << endl;
cout << setw(60) << "1.New account" << endl;
cout << setw(65) << "2.Existing account" << endl;
cout << setw(56) << "3.Deposit" << endl;
cout << setw(57) << "4.Withdraw" << endl;
cout << setw(62) << "5.Close account" << endl;
cin >> anwser;
}
void N_account(char& anwser,string & name)
{
if (anwser == '1')
{
ofstream outfile;
outfile.open("Accounts.txt",std::ofstream::out|std::ofstream::app);
cout << "Enter in first and last name for new account:";
cin.ignore();
getline(cin, name);
outfile << name;
outfile << '\n';
cout << "Account added" << endl;
outfile.close();
}
}
void Exist(string & name_search,char & anwser,string name_from_file)
{
if (anwser == '2')
{
ifstream infile;
infile.open("Accounts.txt");
cout << "Enter in your account:";
cin.ignore();
getline(cin, name_search);
while (infile >> name_from_file)
{
if (name_from_file == name_search)
{
cout << "Account found: " << name_search << endl;
}
}
infile.close();
}
}
|