Advertisement
Sdub

Untitled

Oct 21st, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include <iostream> //accept pin number and verify if correct
  2.  
  3. using namespace std;
  4. int i,trans;
  5. int pin[4];
  6. int existingPin, trialPin, newPin;
  7.  
  8. void newPinz(){
  9. cout << "Please enter your new PIN: ";
  10. cin >> pin[0];
  11. existingPin=pin[0];
  12.  
  13. }
  14.  
  15. void changePin(){
  16. cout << "Please enter your existing PIN\n";
  17. for(i=0; i<4; i++){
  18. cin >> trialPin;
  19. if(trialPin == existingPin){
  20. cout << "Welcome " << existingPin <<"\n";
  21. cout << "Enter your new PIN ";
  22. cin >> newPin;
  23. existingPin = newPin;
  24. cout << "Your PIN has been changed \n";
  25. cout << endl;
  26. main();
  27. }
  28. else{
  29. cout <<"Error! Please enter PIN : ";}
  30. }
  31. }
  32.  
  33. void existingPinz(){
  34. cout << "Please enter your existing PIN \n";
  35. for (i=1;i<4;i++){
  36. cin >> pin[i];
  37. if(existingPin == pin[i]){
  38. cout << "Validated, Welcome "<< existingPin <<endl;
  39. exit (0);
  40. }
  41. else{
  42. cout << "ERROR! PIN IS INCORRECT\n" << "Try again "<<"\n";
  43. main();
  44. }
  45.  
  46. }
  47. }
  48.  
  49. int main(){
  50.  
  51. cout << "Welcome to BDO: Budie De Oro"<<endl;
  52. cout <<"<1>Enter New PIN" << endl << "<2>Change PIN" << endl<<"<3>Enter Existing PIN"<<endl;
  53. cin >> trans;
  54. switch(trans){
  55. case 1:
  56. newPinz();
  57. main();
  58. case 2:
  59. changePin();
  60. main();
  61. case 3:
  62. existingPinz();
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement