Re: Question on Rectangles
What is this Rectangle class?
If you are using java.awt.Rectangle then there is a method to find intersections. If not - ie if you are writing the Rectangle class - you should concentrate on writing a method that produces a new Rectangle by intersection with some given rectangle.
Then once you have such a Rectangle method (or using the java.awt.Rectangle one) you can write the code to (a) get user input) (b) create rectangles (c)intersect them (d) output the result.
The point is to separate the user input code from the intersection code.
I can't see anything in your statement of the problem that calls for a while loop: ie any action that repeats over and over again. Certainly finding the intersection of two rectangles does not involve any loops.