Question: USE IN JAVA Write a method that behaves like a household security alarm that can be switched off with a special sequence of digits (password).
USE IN JAVA
Write a method that behaves like a household security alarm that can be switched off with a special sequence of digits (password). Write the method so that it takes a String as a parameter. It doesn't need to return anything. The method should print out "Alarm Deactivated" if the String taken as a parameter contains the sequence "1234" anywhere in the input; thus "1234" is the password. Your method should reject any other sequence and any sequence greater than 10 characters. Failure to enter the correct password should result in printing "Alarm Activated" to the screen. The method should use the .matches () method with a regular expression. In the main method call the method with user input
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
