Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 inputStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started