├── .gitignore ├── ATM System.sln ├── ATM System ├── 0 ├── ATM System.cpp ├── ATM System.vcxproj └── ATM System.vcxproj.filters └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual Studio add-ons. 2 | *.obj 3 | *.exe 4 | *.ilk 5 | *.pdb 6 | *.log 7 | *.tlog 8 | *.suo 9 | *.db 10 | .vs/ 11 | x64 12 | *.user -------------------------------------------------------------------------------- /ATM System.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.11.35327.3 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ATM System", "ATM System\ATM System.vcxproj", "{6ED6496A-E789-4FFB-A1B7-E5856BF70DBE}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {6ED6496A-E789-4FFB-A1B7-E5856BF70DBE}.Debug|x64.ActiveCfg = Debug|x64 17 | {6ED6496A-E789-4FFB-A1B7-E5856BF70DBE}.Debug|x64.Build.0 = Debug|x64 18 | {6ED6496A-E789-4FFB-A1B7-E5856BF70DBE}.Debug|x86.ActiveCfg = Debug|Win32 19 | {6ED6496A-E789-4FFB-A1B7-E5856BF70DBE}.Debug|x86.Build.0 = Debug|Win32 20 | {6ED6496A-E789-4FFB-A1B7-E5856BF70DBE}.Release|x64.ActiveCfg = Release|x64 21 | {6ED6496A-E789-4FFB-A1B7-E5856BF70DBE}.Release|x64.Build.0 = Release|x64 22 | {6ED6496A-E789-4FFB-A1B7-E5856BF70DBE}.Release|x86.ActiveCfg = Release|Win32 23 | {6ED6496A-E789-4FFB-A1B7-E5856BF70DBE}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {7ABA45A1-4B1A-49A5-AB34-06F137A477DF} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /ATM System/0: -------------------------------------------------------------------------------- 1 | Press any key to continue . . . 2 | -------------------------------------------------------------------------------- /ATM System/ATM System.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | // AccountNumber:T373 PINcode:3421 9 | 10 | const string ClientsFileName = "C:\\Users\\a\\Desktop\\project cpp\\project level 7\\Bank_\\Bank_\\Clients.txt";// path my file client using ATM 11 | struct sClient 12 | { 13 | string AccountNumber; 14 | string PinCode; 15 | string Name; 16 | string Phone; 17 | double AccountBalance; 18 | bool MarkForDelete = false; 19 | }; 20 | 21 | enum enMainMenueOptions { 22 | enQucikWithdraw = 1, enNormalWithDraw = 2, enDeposit = 3, 23 | enCheckBalance = 4, enExitprogr = 5 24 | }; 25 | 26 | sClient CurrentClient; 27 | 28 | void ShowMainMenue(); 29 | void Login(); 30 | void ShowQuickWithdrawScreen(); 31 | void ShowNormalWithDrawScreen(); 32 | void ShowDepositScreen(); 33 | 34 | vector SplitString(string S1, string Delim) 35 | { 36 | vector vString; 37 | short pos = 0; 38 | string sWord; 39 | while ((pos = S1.find(Delim)) != std::string::npos) 40 | { 41 | sWord = S1.substr(0, pos); 42 | if (sWord != "") 43 | { 44 | vString.push_back(sWord); 45 | } 46 | S1.erase(0, pos + Delim.length()); 47 | } 48 | if (S1 != "") 49 | { 50 | vString.push_back(S1); 51 | } 52 | return vString; 53 | } 54 | 55 | sClient ConvertLinetoRecord(string Line, string Seperator = "#//#") 56 | { 57 | sClient Client; 58 | vector vClientData; 59 | vClientData = SplitString(Line, Seperator); 60 | Client.AccountNumber = vClientData[0]; 61 | Client.PinCode = vClientData[1]; 62 | Client.Name = vClientData[2]; 63 | Client.Phone = vClientData[3]; 64 | Client.AccountBalance = stod(vClientData[4]);//cast string to double 65 | return Client; 66 | } 67 | 68 | string ConvertRecordToLine(sClient Client, string Seperator = "#//#") 69 | { 70 | 71 | string stClientRecord = ""; 72 | 73 | stClientRecord += Client.AccountNumber + Seperator; 74 | stClientRecord += Client.PinCode + Seperator; 75 | stClientRecord += Client.Name + Seperator; 76 | stClientRecord += Client.Phone + Seperator; 77 | stClientRecord += to_string(Client.AccountBalance); 78 | 79 | return stClientRecord; 80 | 81 | } 82 | 83 | vector LoadCleintsDataFromFile(string FileName) 84 | { 85 | 86 | vector vClients; 87 | 88 | fstream MyFile; 89 | MyFile.open(FileName, ios::in);//read 90 | 91 | if (MyFile.is_open()) 92 | { 93 | 94 | string Line; 95 | sClient Client; 96 | 97 | while (getline(MyFile, Line)) 98 | { 99 | 100 | Client = ConvertLinetoRecord(Line); 101 | 102 | vClients.push_back(Client); 103 | } 104 | 105 | MyFile.close(); 106 | 107 | } 108 | 109 | return vClients; 110 | 111 | } 112 | 113 | bool FindClientByAccountNumberAndPinCode(string AccountNumber, string PinCode, sClient& Client) 114 | { 115 | 116 | vector vClients = LoadCleintsDataFromFile(ClientsFileName); 117 | 118 | for (sClient C : vClients) 119 | { 120 | 121 | if (C.AccountNumber == AccountNumber && C.PinCode == PinCode) 122 | { 123 | Client = C; 124 | return true; 125 | } 126 | 127 | } 128 | return false; 129 | 130 | } 131 | 132 | vector SaveCleintsDataToFile(string FileName, vector vClients) 133 | { 134 | 135 | fstream MyFile; 136 | MyFile.open(FileName, ios::out);//write 137 | 138 | string DataLine; 139 | 140 | if (MyFile.is_open()) 141 | { 142 | 143 | for (sClient C : vClients) 144 | { 145 | 146 | if (C.MarkForDelete == false) 147 | { 148 | 149 | DataLine = ConvertRecordToLine(C); 150 | MyFile << DataLine << endl; 151 | 152 | } 153 | 154 | } 155 | 156 | MyFile.close(); 157 | 158 | } 159 | 160 | return vClients; 161 | 162 | } 163 | 164 | bool DepositBalanceToClientByAccountNumber(string AccountNumber, double Amount, vector & vClients) 165 | { 166 | char Answer = 'n'; 167 | 168 | cout << "\n\nAre you sure you want perfrom this transaction? y/n ? "; 169 | cin >> Answer; 170 | if (Answer == 'y' || Answer == 'Y') 171 | { 172 | 173 | for (sClient& C : vClients) 174 | { 175 | if (C.AccountNumber == AccountNumber) 176 | { 177 | C.AccountBalance += Amount; 178 | SaveCleintsDataToFile(ClientsFileName, vClients); 179 | cout << "\n\nDone Successfully. New balance is: " << C.AccountBalance; 180 | 181 | return true; 182 | } 183 | 184 | } 185 | 186 | 187 | return false; 188 | } 189 | 190 | } 191 | 192 | short ReadQuickWithdrawOption() 193 | { 194 | short Choice = 0; 195 | while (Choice < 1 || Choice>9) 196 | { 197 | cout << "\nChoose what to do from [1] to [9] ? "; 198 | cin >> Choice; 199 | } 200 | 201 | return Choice; 202 | } 203 | 204 | short getQuickWithDrawAmount(short QuickWithDrawOption) 205 | { 206 | switch (QuickWithDrawOption) 207 | { 208 | case 1: 209 | return 20; 210 | case 2: 211 | return 50; 212 | case 3: 213 | return 100; 214 | case 4: 215 | return 200; 216 | case 5: 217 | return 400; 218 | case 6: 219 | return 600; 220 | case 7: 221 | return 800; 222 | case 8: 223 | return 1000; 224 | default: 225 | return 0; 226 | 227 | } 228 | 229 | } 230 | 231 | void PerfromQuickWithdrawOption(short QuickWithDrawOption) 232 | { 233 | if (QuickWithDrawOption == 9) { 234 | return; 235 | } 236 | short WithDrawBalance = getQuickWithDrawAmount(QuickWithDrawOption); 237 | 238 | if (WithDrawBalance > CurrentClient.AccountBalance) 239 | { 240 | cout << "\nThe amount exceeds your balance, make another choice.\n"; 241 | cout << "Press Anykey to continue..."; 242 | system("pause>0"); 243 | ShowQuickWithdrawScreen(); 244 | return; 245 | } 246 | 247 | vector vClients = LoadCleintsDataFromFile(ClientsFileName); 248 | DepositBalanceToClientByAccountNumber(CurrentClient.AccountNumber, WithDrawBalance * -1, vClients); 249 | CurrentClient.AccountBalance -= WithDrawBalance; 250 | 251 | 252 | } 253 | 254 | double ReadDepositAmount() 255 | { 256 | double Amount; 257 | cout << "\nEnter a positive Deposit Amount? "; 258 | 259 | cin >> Amount; 260 | while (Amount <= 0) 261 | { 262 | cout << "\nEnter a positive Deposit Amount? "; 263 | cin >> Amount; 264 | } 265 | return Amount; 266 | } 267 | 268 | void PerfromDepositOption() 269 | { 270 | 271 | double DepositAmount = ReadDepositAmount(); 272 | 273 | vector vClients = LoadCleintsDataFromFile(ClientsFileName); 274 | DepositBalanceToClientByAccountNumber(CurrentClient.AccountNumber, DepositAmount, vClients); 275 | CurrentClient.AccountBalance += DepositAmount; 276 | } 277 | 278 | void ShowDepositScreen() 279 | { 280 | system("cls"); 281 | cout << "===========================================\n"; 282 | cout << "\t\tDeposit Screen\n"; 283 | cout << "===========================================\n"; 284 | PerfromDepositOption(); 285 | 286 | } 287 | 288 | void ShowCheckBalanceScreen() 289 | { 290 | system("cls"); 291 | cout << "===========================================\n"; 292 | cout << "\t\tCheck Balance Screen\n"; 293 | cout << "===========================================\n"; 294 | cout << "Your Balance is " << CurrentClient.AccountBalance << "\n"; 295 | 296 | } 297 | 298 | int ReadWithDrawAmont() 299 | { 300 | int Amount; 301 | cout << "\nEnter an amount multiple of 5's ? "; 302 | 303 | cin >> Amount; 304 | 305 | while (Amount % 5 != 0) 306 | { 307 | cout << "\nEnter an amount multiple of 5's ? "; 308 | cin >> Amount; 309 | } 310 | return Amount; 311 | } 312 | 313 | void PerfromNormalWithdrawOption() 314 | { 315 | 316 | int WithDrawBalance = ReadWithDrawAmont(); 317 | 318 | if (WithDrawBalance > CurrentClient.AccountBalance) 319 | { 320 | cout << "\nThe amount exceeds your balance, make another choice.\n"; 321 | cout << "Press Anykey to continue..."; 322 | system("pause>0"); 323 | ShowNormalWithDrawScreen(); 324 | return; 325 | } 326 | 327 | vector vClients = LoadCleintsDataFromFile(ClientsFileName); 328 | DepositBalanceToClientByAccountNumber(CurrentClient.AccountNumber, WithDrawBalance * -1, vClients); 329 | CurrentClient.AccountBalance -= WithDrawBalance; 330 | 331 | 332 | } 333 | 334 | void ShowNormalWithDrawScreen() 335 | { 336 | system("cls"); 337 | cout << "===========================================\n"; 338 | cout << "\t\tNormal Withdraw Screen\n"; 339 | cout << "===========================================\n"; 340 | PerfromNormalWithdrawOption(); 341 | } 342 | 343 | void ShowQuickWithdrawScreen() 344 | { 345 | system("cls"); 346 | cout << "===========================================\n"; 347 | cout << "\t\tQucik Withdraw\n"; 348 | cout << "===========================================\n"; 349 | cout << "\t[1] 20\t\t[2] 50\n"; 350 | cout << "\t[3] 100\t\t[4] 200\n"; 351 | cout << "\t[5] 400\t\t[6] 600\n"; 352 | cout << "\t[7] 800\t\t[8] 1000\n"; 353 | cout << "\t[9] Exit\n"; 354 | cout << "===========================================\n"; 355 | cout << "Your Balance is " << CurrentClient.AccountBalance; 356 | 357 | PerfromQuickWithdrawOption(ReadQuickWithdrawOption()); 358 | } 359 | 360 | void GoBackToMainMenue() 361 | { 362 | cout << "\n\nPress any key to go back to Main Menue..."; 363 | system("pause>0"); 364 | ShowMainMenue(); 365 | } 366 | 367 | short ReadMainMenueOption() 368 | { 369 | cout << "Choose what do you want to do? [1 to 5]? "; 370 | short Choice = 0; 371 | cin >> Choice; 372 | 373 | return Choice; 374 | } 375 | 376 | void PerfromMainMenueOption(enMainMenueOptions MainMenueOption) 377 | { 378 | switch (MainMenueOption) 379 | { 380 | case enMainMenueOptions::enQucikWithdraw: 381 | { 382 | system("cls"); 383 | ShowQuickWithdrawScreen(); 384 | GoBackToMainMenue(); 385 | break; 386 | } 387 | case enMainMenueOptions::enNormalWithDraw: 388 | system("cls"); 389 | ShowNormalWithDrawScreen(); 390 | GoBackToMainMenue(); 391 | break; 392 | 393 | case enMainMenueOptions::enDeposit: 394 | system("cls"); 395 | ShowDepositScreen(); 396 | GoBackToMainMenue(); 397 | break; 398 | 399 | case enMainMenueOptions::enCheckBalance: 400 | system("cls"); 401 | ShowCheckBalanceScreen(); 402 | GoBackToMainMenue(); 403 | break; 404 | 405 | case enMainMenueOptions::enExitprogr: 406 | system("cls"); 407 | Login(); 408 | 409 | break; 410 | } 411 | 412 | } 413 | 414 | void ShowMainMenue() 415 | { 416 | system("cls"); 417 | cout << "===========================================\n"; 418 | cout << "\t\tATM Main Menue Screen\n"; 419 | cout << "===========================================\n"; 420 | cout << "\t[1] Quick Withdraw.\n"; 421 | cout << "\t[2] Normal Withdraw.\n"; 422 | cout << "\t[3] Deposit\n"; 423 | cout << "\t[4] Check Balance.\n"; 424 | cout << "\t[5] Logout.\n"; 425 | cout << "===========================================\n"; 426 | 427 | 428 | PerfromMainMenueOption((enMainMenueOptions)ReadMainMenueOption()); 429 | } 430 | 431 | bool LoadClientInfo(string AccountNumber, string PinCode) 432 | { 433 | 434 | if (FindClientByAccountNumberAndPinCode(AccountNumber, PinCode, CurrentClient)) 435 | return true; 436 | else 437 | return false; 438 | } 439 | 440 | void Login() 441 | { 442 | bool LoginFaild = false; 443 | string AccountNumber, PinCode; 444 | do 445 | { 446 | system("cls"); 447 | cout << "\n---------------------------------\n"; 448 | cout << "\tLogin Screen"; 449 | cout << "\n---------------------------------\n"; 450 | 451 | if (LoginFaild) 452 | { 453 | cout << "Invlaid Account Number/PinCode!\n"; 454 | } 455 | 456 | cout << "Enter Account Number? "; 457 | cin >> AccountNumber; 458 | 459 | cout << "Enter Pin? "; 460 | cin >> PinCode; 461 | LoginFaild = !LoadClientInfo(AccountNumber, PinCode); 462 | } while (LoginFaild); 463 | ShowMainMenue(); 464 | } 465 | 466 | int main() 467 | 468 | { 469 | Login(); 470 | system("pause>0"); 471 | return 0; 472 | } 473 | -------------------------------------------------------------------------------- /ATM System/ATM System.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 17.0 23 | Win32Proj 24 | {6ed6496a-e789-4ffb-a1b7-e5856bf70dbe} 25 | ATMSystem 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | Unicode 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | Unicode 41 | 42 | 43 | Application 44 | true 45 | v143 46 | Unicode 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | Unicode 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Level3 76 | true 77 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 78 | true 79 | 80 | 81 | Console 82 | true 83 | 84 | 85 | 86 | 87 | Level3 88 | true 89 | true 90 | true 91 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 92 | true 93 | 94 | 95 | Console 96 | true 97 | true 98 | true 99 | 100 | 101 | 102 | 103 | Level3 104 | true 105 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 106 | true 107 | 108 | 109 | Console 110 | true 111 | 112 | 113 | 114 | 115 | Level3 116 | true 117 | true 118 | true 119 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 120 | true 121 | 122 | 123 | Console 124 | true 125 | true 126 | true 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /ATM System/ATM System.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🏦 ATM Simulator System 2 | 3 | A command-line ATM simulator that allows users to manage bank accounts, perform transactions, and check balances. 4 | 5 | ## ✨ Features 6 | 7 | - **🔐 Login Screen**: Authenticate using account number and PIN. 8 | - **📋 Main Menu**: 9 | - **⚡ Quick Withdraw**: Predefined withdrawal amounts (20, 50, 100, 200, 400, 600, 800, 1000). 10 | - **💸 Normal Withdraw**: Custom withdrawal amount (multiples of 5). 11 | - **💰 Deposit**: Add funds to the account. 12 | - **📊 Check Balance**: View current account balance. 13 | - **🚪 Logout**: Return to the login screen. 14 | - **📁 File Storage**: Client data stored in `Clients.txt`. 15 | 16 | ## 🛠️ Installation 17 | 18 | 1. **Clone the Repository**: 19 | ~~~ 20 | git clone https://github.com/TariqCodeBit/ATM-System.git 21 | ~~~ 22 | 23 | ## Author 24 | - The Game was developed by **Tarek**. 25 | --------------------------------------------------------------------------------