Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program (the class name TwoConsecutive) that accepts three integer inputs and displays true if there is at least one pair of integers

Write a program (the class name TwoConsecutive) that accepts three integer inputs and displays true if there is at least one pair of integers that differ by exactly 1. For example, the integers 3 and 4 differ by 1. The integers 12 and 11 also differ by 1. Your program should display false if there are no such consecutive values. The integers could be input in any order; the two consecutive values could be any of the two values input. Here are some sample runs: Input Output 1, 2, 12 true 1, 12, 2 true 2, 12, 1 true 4, 5, 3 true 2, 4, 6 false 8, 8, 8 false

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

Probability And Statistics For Engineering And The Sciences

Authors: Jay L. Devore

9th Edition

1305251806, 978-1305251809

More Books

Students also viewed these Programming questions