Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.84 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <fstream>
  4. #include <cstdlib>
  5. #include <windows.h>
  6. #include <conio.h>
  7.  
  8. using namespace std;
  9. short pinO, pin, pinZMIANA;
  10. string linia;
  11. int64_t StanKonta, kwotaWPLAC, kwotaWYPLAC;
  12. char kontoWybor;
  13.  
  14. int main()
  15. {
  16. cout<<"=-=-=-=-=-=-=-=-=-=-=-="<<endl;
  17. cout<<" Witamy w naszym banku "<<endl;
  18. cout<<"=-=-=-=-=-=-=-=-=-=-=-="<<endl;
  19. cout<<"Wprowadz PIN: ";
  20. cin>>pinO;
  21.  
  22. fstream pinODCZYT;
  23. pinODCZYT.open("pin.txt", ios::in);
  24. pinODCZYT>>pin;
  25. pinODCZYT.close();
  26. while(1){
  27. if(pinO==pin)
  28. {
  29.  
  30. fstream konto;
  31. konto.open("konto.txt", ios::in);
  32. konto>>StanKonta;
  33. konto.close();
  34.  
  35.  
  36.  
  37.  
  38. system("cls");
  39.  
  40. cout<<"=-=-=-=-=-=-=-=-=-=-=-="<<endl;
  41. cout<<"Stan konta wynosi: "<<StanKonta<<endl;
  42. cout<<"=-=-=-=-=-=-=-=-=-=-=-="<<endl;
  43. cout<<"1.Wplac pieniadze"<<endl;
  44. cout<<"2.Wyplac pieniadze"<<endl;
  45. cout<<"3.Zmien pin"<<endl;
  46. cout<<"4.Wyjscie"<<endl;
  47.  
  48. kontoWybor=getch();
  49.  
  50.  
  51. if(kontoWybor=='1')
  52. {
  53. cout<<"Wprowadz kwote: ";
  54. cin>>kwotaWPLAC;
  55. fstream StanKontaP;
  56. if(kwotaWPLAC>0)
  57. {
  58. StanKontaP.open("konto.txt", ios::out);
  59. StanKonta=StanKonta+kwotaWPLAC;
  60. StanKontaP<<StanKonta;
  61. StanKontaP.close();
  62. }
  63. else
  64. {
  65. cout<<"Nie poprawna kwota"<<endl;
  66. Sleep(2000);
  67. }
  68.  
  69.  
  70.  
  71.  
  72. }
  73. else if(kontoWybor=='2')
  74. {
  75.  
  76. cout<<"Wprowadz kwote: ";
  77. cin>>kwotaWYPLAC;
  78.  
  79. if(kwotaWYPLAC>0&& kwotaWYPLAC<=StanKonta) /*Nie wyplaci sie wiecej niz sie ma C:*/
  80. {
  81. fstream StanKontaP;
  82. StanKontaP.open("konto.txt", ios::out);
  83. StanKonta=StanKonta-kwotaWYPLAC;
  84. StanKontaP<<StanKonta;
  85. StanKontaP.close();
  86. }
  87. else
  88. {
  89. cout<<"Nie poprawna kwota lub za duzo chcesz wyplacic"<<endl;
  90. Sleep(2000);
  91. }
  92.  
  93. }
  94. else if(kontoWybor=='3')
  95. {
  96. cout<<"Podaj nowy pin: ";
  97. cin>>pinZMIANA;
  98. fstream pinODCZYT;
  99. pinODCZYT.open("pin.txt", ios::out);
  100. pinODCZYT<<pinZMIANA;
  101. pinODCZYT.close();
  102. system("cls");
  103. main(); /*Po zmianie pinu trzeba go ponownie podac jak w prawdziwych bankach*/
  104. }
  105. else if(kontoWybor=='4')
  106. {
  107. break;
  108.  
  109. }
  110. else
  111. {
  112. cout << "Nie poprawny ZNAK"<<endl;
  113. Sleep(2000);
  114. system("cls");
  115. }
  116.  
  117.  
  118. }
  119.  
  120.  
  121. else
  122. {
  123. cout << "Nie poprawny PIN"<<endl;
  124. Sleep(2000);
  125. system("cls");
  126. main();
  127. }
  128.  
  129. }
  130.  
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement