Answered step by step
Verified Expert Solution
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:
- Two integers are "close" to each other if their values differ from each other by at most one.
- 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:
- Input integer 1: 1 Input integer 2: 2 Input integer 3: 10 Result: true
Execution 2:
- Input integer 1: 1 Input integer 2: 2 Input integer 3: 3 Result: false
Execution 3:
- Input integer 1: 10 Input integer 2: 8 Input integer 3: 9 Result: false
Execution 4:
- 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
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