Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions