Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream> //accept pin number and verify if correct
- using namespace std;
- int i,trans;
- int pin[4];
- int existingPin, trialPin, newPin;
- void newPinz(){
- cout << "Please enter your new PIN: ";
- cin >> pin[0];
- existingPin=pin[0];
- }
- void changePin(){
- cout << "Please enter your existing PIN\n";
- for(i=0; i<4; i++){
- cin >> trialPin;
- if(trialPin == existingPin){
- cout << "Welcome " << existingPin <<"\n";
- cout << "Enter your new PIN ";
- cin >> newPin;
- existingPin = newPin;
- cout << "Your PIN has been changed \n";
- cout << endl;
- main();
- }
- else{
- cout <<"Error! Please enter PIN : ";}
- }
- }
- void existingPinz(){
- cout << "Please enter your existing PIN \n";
- for (i=1;i<4;i++){
- cin >> pin[i];
- if(existingPin == pin[i]){
- cout << "Validated, Welcome "<< existingPin <<endl;
- exit (0);
- }
- else{
- cout << "ERROR! PIN IS INCORRECT\n" << "Try again "<<"\n";
- main();
- }
- }
- }
- int main(){
- cout << "Welcome to BDO: Budie De Oro"<<endl;
- cout <<"<1>Enter New PIN" << endl << "<2>Change PIN" << endl<<"<3>Enter Existing PIN"<<endl;
- cin >> trans;
- switch(trans){
- case 1:
- newPinz();
- main();
- case 2:
- changePin();
- main();
- case 3:
- existingPinz();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement