Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I would like help answering this Java question. I am suppose to answer using if - else Statements as a beginner. Please explain in

Hello, I would like help answering this Java question. I am suppose to answer using if - else Statements as a beginner. Please explain in detail what you do.

Here is the question:

Assume the following rules:

  1. Two integers are "close" to each other if their values differ from each other by at most one.
  2. Two integers are "far" to each other if their values differ from each other by two or more.

Write a program that asks the user to input three int values, a, b, and c. Display true if one of b or c is "close" to a and the other is "far" from the other two. Otherwise, display false. Execution 1:

  1. Input integer 1: 1 Input integer 2: 2 Input integer 3: 10 Result: true

Execution 2:

  1. Input integer 1: 1 Input integer 2: 2 Input integer 3: 3 Result: false

Execution 3:

  1. Input integer 1: 10 Input integer 2: 8 Input integer 3: 9 Result: false

Execution 4:

  1. Input integer 1: -1 Input integer 2: 10 Input integer 3: 0 Result: true

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

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions

Question

What is JIT II?

Answered: 1 week ago

Question

In what ways are you similar to your closest friends?

Answered: 1 week ago

Question

KEY QUESTION Refer to columns 1 and 6 in the table for question

Answered: 1 week ago