Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Barking Dog We have a dog that likes to bark. We need to wake up if the dog is barking at night! Write a method
Barking Dog We have a dog that likes to bark. We need to wake up if the dog is barking at night! Write a method shouldWakeUp that has 2 parameters. 1st parameter should be of type boolean and be named barking it represents if our dog is currently barking. 2nd parameter represents the hour of the day and is of type int with the name hourOfDay and has a valid range of 0-23 We have to wake up if the dog is barking before 8 or after 22 hours so in that case return true. In all other cases return false. If the hourOfDay parameter is less than 0 or greater than 23 return false. Examples of input/output: shouldWakeUp (true, 1); should return true shouldwakeUp (false, 2); should return false since the dog is not barking. . shouldwakeUp (true, 8); should return false, since it's not before 8. shouldwakeUp (true, -1); - should return false since the hourOfDay parameter needs to be in a range 0-23. TIP: Use the if else statement with multiple conditions. NOTE: The shouldWakeUp method needs to be defined as public static like we have been doing so far in the course. NOTE: Do not add a main method to solution code
Step 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