Question: Write in JAVA Several seasons of hot summers and cold winters have taken their toll on Farmer John's fence, and he decides it is time
Write in JAVA
Several seasons of hot summers and cold winters have taken their toll on Farmer John's fence, and he decides it is time to repaint it along with the help of his favo
rite cow, Bessie. Unfortunately, while Bessie is actually remarkably proficient at painting, she is not as good at understanding Farmer John's instructions.
If we regard the fence as a onedimensional number line, Farmer John paints the interval between a and For example, if and then Farmer John pa
ints an interval of length Bessie, misunderstanding Farmer John's instructions, paints the interval from to which may possibly overlap with part or all of
Farmer John's interval. Please determine the total length of fence that is now covered with paint.
Input
The first line of the input contains the integers a and separated by a space cda,dots
Description
Several seasons of hot summers and cold winters have taken their toll on Farmer John's fence, and he decides it is time to repaint it along with the help of his favorite cow, Bessie. Unfortunately, while Bessie is actually remarkably proficient at painting, she is not as good at understanding Farmer John's instructions.
If we regard the fence as a onedimensional number line, Farmer John paints the interval between xa and xb For example, if a and b then Farmer John paints an interval of length Bessie, misunderstanding Farmer John's instructions, paints the interval from xc to xd which may possibly overlap with part or all of Farmer John's interval. Please determine the total length of fence that is now covered with paint.
Input
The first line of the input contains the integers a and b separated by a space
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
