Password protected - security door

hey how are you hope all are fine i have here project about Password protected - security door can any one help about this project i need the code i made it by using if statement but the dr he is asking you have to use function i made it but they is some wrong i don't know what it is any one know plz help me doing it my presentation tomorrow here is the code

// C++ final Project ( Password protected - security door )
#include <iostream>
using namespace std;

void exit(char);
void main()
{
int password, i; char choise; // declaring variables

next :

cout<<"\nPlease enter the password (Pin) :\n ";

cin>>password; // input statement

if(password==1792)
{ // control statement
cout<<"\nOpen the door\n"<<endl;
goto label1;
}

else (password != 1792 );


{cout<<"\nWrong password please try again ! you just have 3 attempts \n"<<endl;}


for(int i=1; i <4 ; i++)
{
cout<<"\nTry the password "<<i<<endl ;
cin>>password;

if(password==1792)
{
cout<<"\nOpen the door\n"<<endl; goto label;
}

}
cout<<"\n\nAlarm triggered\n"<<endl;




label1:
char choise; cout<<"\ncontinue (y/n) : "<<endl;
cin>>choise;
choise=exit(char);
system ("pause");

}


void exit(char choise)
{
char choise;

if(choise=='y') goto next;

label :


}

am waiting for the answer and thx for alll
Last edited on
"Use a function" is a bit vague.

You could make a function that takes an integer, checks to see if it matches the pin, returns true if it does and false if it doesn't.

You could make a function that does everything in it, all of the i/o, checking password etc.

When you hand in your work, be sure to slap him in the face on behalf of the C++ community for perpetuating the poor use of flow control thanks to those goto statements.

thanks for your comment but u can do it and send it to me because really am confused from this project so can you do it and send it to me back
thanks for your comment
closed account (1vRz3TCk)
I would not wait for others to do it for you, I doubt it will happen.
thxxx for your comment
Topic archived. No new replies allowed.