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 JAVAUSE IN JAVA Write a method that behaves like a household security

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!