How to make a java code which will take a PIN and if it's true, it will perform the functions of class A otherwise it will omit? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to make a java code which will take a PIN and if it's true, it will perform the functions of class A otherwise it will omit?

15th Jul 2019, 11:31 AM
Malvika Chauhan
Malvika Chauhan - avatar
2 Answers
+ 3
First, you will have to need some kind of input. This can be an alert-prompt, or an input-field. Then, when the user wants to continue, you could use an if-statement to check if the input contains the correct PIN. If the PIN is incorrect, you can return false and whatever message you'd like.
15th Jul 2019, 11:49 AM
Roolin
Roolin - avatar
+ 2
var pass= prompt("Enter Password"); if (pass == 0000) // replace "0000" with your desired password {alert("allowed."); //some code } else {alert("not allowed"); }
15th Jul 2019, 12:35 PM
SHIVAM
SHIVAM - avatar