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

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!