fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. #include <conio.h>
  5. #include <sstream>
  6. using namespace std;
  7. //struct lol{
  8. //
  9. //int pass;
  10. //string user;
  11. //
  12. //};
  13. //int main()
  14. //{
  15. // lol clints[100];
  16. // cin>>clints[0].pass;
  17. // cin>>clint1[0].user;
  18. // int arr[100];
  19. //
  20. //}
  21. string fname,lname,address,telephone,mobile,email,password="",repassword;
  22. string naddress,ntelephone,nmobile,nemail,npassword,nrepassword;
  23. int balancee=0,id=rand();
  24. void firstname()
  25. {
  26. char ch;
  27. do
  28. {
  29. cout<<"Please enter your first name"<<endl;
  30. getline(cin,fname);
  31. ch=' ';
  32. for(int i=0 ; i<fname.size() ; i++)
  33. {
  34. if(i==fname.size()-1);
  35. break;
  36. if(fname[i+1]<'a' || fname[i+1]>'z' || fname[0]<'A' || fname[0]>'Z')
  37. {
  38. cout<<"Please enter a valid name."<<endl;
  39. cout<<"Press y to contniue."<<endl;
  40. cin>>ch;
  41. cin.ignore();
  42. break;
  43. }
  44. }
  45. }while(ch=='y');
  46. }
  47.  
  48. void lastname()
  49. {
  50. char ch;
  51. do
  52. {
  53. cout<<"Please enter your last name"<<endl;
  54. getline(cin,lname);
  55. ch=' ';
  56. for(int i=0 ; i<lname.size() ; i++)
  57. {
  58. if(i==lname.size()-1);
  59. break;
  60. if(lname[i+1]<'a' || lname[i+1]>'z' || lname[0]<'A' || lname[0]>'Z')
  61. {
  62. cout<<"Please enter a valid name."<<endl;
  63. cout<<"Press y to contniue."<<endl;
  64. cin>>ch;
  65. cin.ignore();
  66. }
  67. }
  68. }while(ch=='y');
  69. }
  70.  
  71. void telephonenum()
  72. {
  73. char ch;
  74. do
  75. {
  76. cout<<"Please enter your telephone number."<<endl;
  77. getline(cin,telephone);
  78. ch=' ';
  79. for(int i=0 ; i<telephone.size() ; i++)
  80. {
  81. if(telephone.size()!=8 || telephone[i]<'0' || telephone[i]>'9')
  82. {
  83. cout<<"Please enter a valid telephone number."<<endl;
  84. cout<<"Press y to contniue."<<endl;
  85. cin>>ch;
  86. cin.ignore();
  87. break;
  88. }
  89. }
  90. }while(ch=='y');
  91. }
  92.  
  93. void mobilenum()
  94. {
  95. char ch;
  96. do
  97. {
  98. cout<<"Please enter your mobile number."<<endl;
  99. getline(cin,mobile);
  100. ch=' ';
  101. for(int i=0 ; i<mobile.size() ; i++)
  102. {
  103. if(mobile.size()!=11 || mobile[i]<'0' || mobile[i]>'9')
  104. {
  105. cout<<"Please enter a valid telephone number."<<endl;
  106. cout<<"Press y to contniue."<<endl;
  107. cin>>ch;
  108. cin.ignore();
  109. break;
  110. }
  111. }
  112. }while(ch=='y');
  113. }
  114.  
  115. void deposite()
  116. {
  117. char ch;
  118. int money;
  119. do
  120. {
  121. cout<<"Your balance is "<<balancee<<endl;
  122. cout<<"Please enter an amount of money to be deposited"<<endl;
  123. cin>>money;
  124. balancee+=money;
  125. cout<<"Your balance is "<<balancee<<endl;
  126. cout<<"If you want to deposite again,press y"<<endl;
  127. cin>>ch;
  128. }while(ch=='y');
  129.  
  130. }
  131.  
  132. void withdraw()
  133. {
  134. char ch;
  135. int money;
  136. do
  137. {
  138. cout<<"Your balance is "<<balancee<<endl;
  139. cout<<"Please enter an amount of money to be withdrawn"<<endl;
  140. cin>>money;
  141. if(balancee>money && money>0)
  142. {
  143. balancee-=money;
  144. cout<<"Your balance is "<<balancee<<endl;
  145. }
  146. else
  147. {
  148. cout<<"Your balance is not enough..Please enter a valid amount"<<endl;
  149. }
  150. cout<<"If you want to withdraw again,press y"<<endl;
  151. cin>>ch;
  152. }while(ch=='y');
  153. }
  154.  
  155. void balance()
  156. {
  157. char ch;
  158. do
  159. {
  160. cout<<"Your balance is "<<balancee<<endl;
  161. cout<<"If you want to see your balance again,press y"<<endl;
  162. cin>>ch;
  163. }while(ch=='y');
  164. }
  165.  
  166.  
  167. void eaddress()
  168. {
  169. char ch;
  170. do
  171. {
  172. cout<<"Please enter your new address."<<endl;
  173. getline(cin,naddress);
  174. ch=' ';
  175. address=naddress;
  176. cout<<"If you want modify again press y"<<endl;
  177. cin>>ch;
  178. cin.ignore();
  179. }while(ch=='y');
  180. }
  181.  
  182. void etelephone()
  183. {
  184. char ch;
  185. do
  186. {
  187. cout<<"Please enter your new telephone number."<<endl;
  188. getline(cin,ntelephone);
  189. ch=' ';
  190. for(int i=0 ; i<ntelephone.size() ; i++)
  191. {
  192. if(ntelephone.size()!=8 || ntelephone[i]<'0' || ntelephone[i]>'9')
  193. {
  194. cout<<"Please enter a valid telephone number."<<endl;
  195. break;
  196. }
  197. else
  198. {
  199. telephone=ntelephone;
  200. break;
  201. }
  202. }
  203. cout<<"If you want modify again press y"<<endl;
  204. cin>>ch;
  205. cin.ignore();
  206. }while(ch=='y');
  207. }
  208.  
  209. void emobile()
  210. {
  211. char ch;
  212. do
  213. {
  214. cout<<"Please enter your new mobile number."<<endl;
  215. getline(cin,nmobile);
  216. ch=' ';
  217. for(int i=0 ; i<nmobile.size() ; i++)
  218. {
  219. if(nmobile.size()!=11 || nmobile[i]<'0' || nmobile[i]>'9')
  220. {
  221. cout<<"Please enter a valid mobile number."<<endl;
  222. break;
  223. }
  224. else
  225. {
  226. mobile=nmobile;
  227. break;
  228. }
  229. }
  230. cout<<"If you want modify again press y"<<endl;
  231. cin>>ch;
  232. cin.ignore();
  233. }while(ch=='y');
  234. }
  235.  
  236. void eemail()
  237. {
  238. char ch;
  239. do
  240. {
  241. cout<<"Please enter your new e-mail."<<endl;
  242. getline(cin,nemail);
  243. ch=' ';
  244. email=nemail;
  245. cout<<"If you want modify again press y"<<endl;
  246. cin>>ch;
  247. cin.ignore();
  248. }while(ch=='y');
  249. }
  250.  
  251. void epassword()
  252. {
  253. char ch1;
  254. do
  255. {
  256. char ch2;
  257. do
  258. {
  259. cout<<"Please enter your new password."<<endl;
  260. getline(cin,npassword);
  261. ch2=' ';
  262. cout<<"Please re-enter your password"<<endl;
  263. getline(cin,nrepassword);
  264. if(npassword==nrepassword)
  265. {
  266. password=npassword;
  267. }
  268. else
  269. {
  270. cout<<"The passwords are not identical..Please try again"<<endl;
  271. cout<<"Press y to re-type again"<<endl;
  272. cin>>ch2;
  273. cin.ignore();
  274. }
  275. }while(ch2=='y');
  276. cout<<"If you want modify again press y"<<endl;
  277. cin>>ch1;
  278. cin.ignore();
  279. }while(ch1=='y');
  280. }
  281.  
  282. void edit()
  283. {
  284. char ch=' ';
  285. do
  286. {
  287. int choice;
  288. cout<<"What information would you like to edit ?"<<endl;
  289. cout<<"1-Address."<<endl;
  290. cout<<"2-Telephone."<<endl;
  291. cout<<"3-Mobile."<<endl;
  292. cout<<"4-E-mail."<<endl;
  293. cout<<"5-Password."<<endl;
  294. cin>>choice;
  295. switch (choice)
  296. {
  297. case 1:
  298. eaddress();
  299. break;
  300. case 2:
  301. etelephone();
  302. break;
  303. case 3:
  304. emobile();
  305. break;
  306. case 4:
  307. eemail();
  308. break;
  309. case 5:
  310. epassword();
  311. break;
  312. default:
  313. cout<<"Please enter a valid option."<<endl;
  314. break;
  315. }
  316. cout<<"If you want to edit again,please enter y"<<endl;
  317. cin>>ch;
  318. }while(ch=='y');
  319. }
  320.  
  321. int save()
  322. {
  323. string line1,line2,line;
  324. ifstream myfile("1.txt");
  325. myfile.is_open();
  326. for(int i=0 ; i<2 ; i++)
  327. {
  328. getline(myfile,line);
  329. }
  330. while(myfile.good())
  331. {
  332. getline(myfile,line1);
  333. if(line1==fname)
  334. {
  335. getline(myfile,line2);
  336. if(line2==lname)
  337. {
  338. ofstream myfile ("1.txt");
  339. myfile.is_open();
  340. myfile<<id<<endl<<password<<endl<<fname<<endl<<lname<<endl<<address<<endl;
  341. myfile<<telephone<<endl<<mobile<<endl<<email<<endl<<balancee<<endl;
  342. myfile.close();
  343. return 0;
  344. }
  345. }
  346. else
  347. {
  348. if(myfile.good())
  349. {
  350. for(int i=0 ; i<8 ; i++)
  351. {
  352. getline(myfile,line);
  353. }
  354. continue;
  355. }
  356. else
  357. {
  358. ofstream myfile ("1.txt",ios::app);
  359. myfile.is_open();
  360. myfile<<id<<endl<<password<<endl<<fname<<endl<<lname<<endl<<address<<endl;
  361. myfile<<telephone<<endl<<mobile<<endl<<email<<endl<<balancee<<endl;
  362. myfile.close();
  363. return 0;
  364. }
  365. }
  366. }
  367. while(!myfile.good())
  368. {
  369. ofstream myfile ("1.txt",ios::app);
  370. myfile.is_open();
  371. myfile<<id<<endl<<password<<endl<<fname<<endl<<lname<<endl<<address<<endl;
  372. myfile<<telephone<<endl<<mobile<<endl<<email<<endl<<balancee<<endl;
  373. myfile.close();
  374. break;
  375. }
  376. return 0;
  377. }
  378.  
  379. void menu()
  380. {
  381. char ch=' ';
  382. do
  383. {
  384. cout<<"Please choose one of these operations."<<endl;
  385. cout<<"1-Deposite Money."<<endl;
  386. cout<<"2-Withdraw Money."<<endl;
  387. cout<<"3-Show Your Balance."<<endl;
  388. cout<<"4-Edit your information"<<endl;
  389. cout<<"Press the number of the wanted operation."<<endl;
  390. int choice;
  391. cin>>choice;
  392. switch (choice)
  393. {
  394. case 1:
  395. deposite();
  396. break;
  397. case 2:
  398. withdraw();
  399. break;
  400. case 3:
  401. balance();
  402. break;
  403. case 4:
  404. edit();
  405. break;
  406. default:
  407. save();
  408. break;
  409. }
  410. cout<<"If you want another operation press y."<<endl;
  411. cin>>ch;
  412. if(ch!='y')
  413. save();
  414. }while(ch=='y');
  415. }
  416.  
  417. void registeration()
  418. {
  419. cin.ignore();
  420. firstname();
  421. lastname();
  422. cout<<"Please enter you address."<<endl;
  423. getline(cin,address);
  424. telephonenum();
  425. mobilenum();
  426. cout<<"Please enter you e-mail."<<endl;
  427. getline(cin,email);
  428. cout<<"Your account ID is "<<id<<endl;
  429. char ch=' ';
  430. do
  431. {
  432. cout<<"Please enter a password to be saved for your account."<<endl;
  433. getline(cin,password);
  434. cout<<"Please re-type your password."<<endl;
  435. getline(cin,repassword);
  436. if(password==repassword)
  437. {
  438. cout<<"Congratulations!..You have successfully created your account."<<endl;
  439. cout<<"If you want to proceed press 1"<<endl;
  440. cout<<"Or save your data by pressing 2"<<endl;
  441. int choice;
  442. cin>>choice;// to enter his choice
  443. if(choice==1)
  444. {
  445. menu();
  446. }
  447. else if(choice==2)
  448. {
  449. save();
  450. }
  451. }
  452. else
  453. {
  454. cout<<"The passwords are not identical..Please try again."<<endl;
  455. cout<<"Press y to retype."<<endl;
  456. cin>>ch;
  457. cin.ignore();
  458. }
  459.  
  460. }while(ch=='y');
  461. }
  462.  
  463. void load()
  464. {
  465. cin.ignore();
  466. int lid;
  467. string lpassword;
  468. string line1,line2,line;
  469. string lfname,llname,laddress,ltelephone,lmobile,lemail,lbalance;
  470. char ch=' ';
  471. do
  472. {
  473. cout<<"Please enter you ID"<<endl;
  474. cin>>lid;
  475. cin.ignore();
  476. cout<<"Please enter your password"<<endl;
  477. getline(cin,lpassword);
  478. ifstream myfile("1.txt");
  479. myfile.is_open();
  480. while(myfile.good())
  481. {
  482. getline(myfile,line1);
  483. stringstream convert1(line1);
  484. int res;
  485. if(!(convert1>>res))
  486. res=0;
  487. if(lid==res)
  488. {
  489. getline(myfile,line2);
  490. if(lpassword==line2)
  491. {
  492. id=lid;
  493. password=lpassword;
  494. getline(myfile,lfname);
  495. fname=lfname;
  496. getline(myfile,llname);
  497. lname=llname;
  498. getline(myfile,laddress);
  499. address=laddress;
  500. getline(myfile,ltelephone);
  501. telephone=ltelephone;
  502. getline(myfile,lmobile);
  503. mobile=lmobile;
  504. getline(myfile,lemail);
  505. email=lemail;
  506. getline(myfile,lbalance);
  507. stringstream convert(lbalance);
  508. if(!(convert>>balancee))
  509. balancee=0;
  510. ch=' ';
  511. cout<<"If you want to proceed press 1."<<endl;
  512. cout<<"Or press 2 to save your data."<<endl;
  513. int choice;
  514. cin>>choice;
  515. if(choice==1)
  516. {
  517. menu();
  518. break;
  519. }
  520. else if(choice==2)
  521. {
  522. save();
  523. break;
  524. }
  525.  
  526. }
  527. else
  528. {
  529.  
  530. cout<<"Your ID is invlaid..Press y to try again."<<endl;
  531. cin>>ch;
  532. cin.ignore();
  533. break;
  534. }
  535. }
  536. else
  537. {
  538. if(myfile.good())
  539. {
  540. for(int i=0 ; i<8 ; i++)
  541. {
  542. getline(myfile,line);
  543. }
  544. continue;
  545. }
  546. else
  547. {
  548. cout<<"Your ID is invlaid..Press y to try again."<<endl;
  549. cin>>ch;
  550. cin.ignore();
  551. break;
  552. }
  553.  
  554. }
  555. }
  556. }while(ch=='y');
  557. }
  558.  
  559. int main ()
  560. {
  561. system("Color 1A");
  562. char ch=' ';
  563. do
  564. {
  565. cout<<"Welcome to BANQUE DE LA FCIS!"<<endl;
  566. cout<<"If you are a new client press 1."<<endl;
  567. cout<<"If you already have an account in the bank press 2."<<endl;
  568. int choice;
  569. cin>>choice; // to identify which he/she is a new client or an existing client
  570. if(choice==1)// if he/she is a new client
  571. {
  572. registeration();
  573. }
  574. else if(choice==2)// if he/she is an existing user
  575. {
  576. load();
  577. }
  578. else
  579. {
  580. cout<<"Error..Please select a valid option."<<endl;
  581. cout<<"Press y to continue"<<endl;
  582. cin>>ch;
  583. }
  584. }while(ch=='y');
  585. return 0;
  586. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:4:19: error: conio.h: No such file or directory
prog.cpp:23: error: ‘rand’ was not declared in this scope
prog.cpp: In function ‘void firstname()’:
prog.cpp:32: warning: comparison between signed and unsigned integer expressions
prog.cpp:34: warning: comparison between signed and unsigned integer expressions
prog.cpp: In function ‘void lastname()’:
prog.cpp:56: warning: comparison between signed and unsigned integer expressions
prog.cpp:58: warning: comparison between signed and unsigned integer expressions
prog.cpp: In function ‘void telephonenum()’:
prog.cpp:79: warning: comparison between signed and unsigned integer expressions
prog.cpp: In function ‘void mobilenum()’:
prog.cpp:101: warning: comparison between signed and unsigned integer expressions
prog.cpp: In function ‘void etelephone()’:
prog.cpp:190: warning: comparison between signed and unsigned integer expressions
prog.cpp: In function ‘void emobile()’:
prog.cpp:217: warning: comparison between signed and unsigned integer expressions
prog.cpp: In function ‘int main()’:
prog.cpp:561: error: ‘system’ was not declared in this scope
stdout
Standard output is empty