Question
Write a static method named containsClosePair that accepts a Scanner object as a parameter. The method should read three, and only three, integers from the
Write a static method named containsClosePair that accepts a Scanner object as a parameter. The method should read three, and only three, integers from the Scanner and returns true if there is (at least) one pair of those three integers that differ exactly by 1. For example, the integers 1 and 2 differ by 1, so entering the three integers "1 5 2" containing the pair 1 and 2 would return true. The integers 12 and 11 also differ by 1. Your method should return false if there are no such values separated by exactly 1 in the user input. The user always inputs 3 valid integers separated by spaces. You do not need to print a prompt for the user.
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