do{ // beginning of 'do-while' loop
rectAcreate(xCordA, yCordA, widthA, heightA); //creating rectangles A & B
rectBcreate(xCordB, yCordB, widthB, heightB); //
doesRectIntersPointorNotInters(rectA, rectB); //check to see if the rectangles do not intersect or if they intersect at point
if (rectInterAtPoint == true)
System.out.println("The rectangles intersect at the following point: " + pointIntersect);
else
rectInterAtPoint = false;
if (rectDoesNotIntersect == true)
System.out.println("The rectangles do not intersect.");
else
rectDoesNotIntersect = false;
if ((rectInterAtPoint == false) && (rectDoesNotIntersect == false))
rectIntersect(rectA, rectB); //calculating/printing the intersection
rectUnion(rectA, rectB); // calculating/printing the union
keepGoing = false;
System.out.print("Do you want to study two more rectangles>"); // *** here is the problem, don't know why can't input
String response = scan.nextLine(); // wtf??
if (response.startsWith("y"))
{
keepGoing = true;
}
if (response.startsWith("y"))
{
keepGoing = true;
}
}while(keepGoing == true);
Here is program output:
Quote
Please enter the x coordinate of the upper left corner>10
Please enter the y coordinate of the upper left corner>10
Please enter the x coordinate of the lower right corner>15
Please enter the y coordinate of the lower right corner>15
Please enter the x coordinate of the upper left corner>12
Please enter the y coordinate of the upper left corner>12
Please enter the x coordinate of the lower right corner>20
Please enter the y coordinate of the lower right corner>20
The intersection of these two rectangles is the rectangle: java.awt.Rectangle[x=12,y=12,width=13,height=13]
The union of these two rectangles is the rectangle: java.awt.Rectangle[x=10,y=10,width=22,height=22]
Do you want to study two more rectangles>
Please enter the y coordinate of the upper left corner>10
Please enter the x coordinate of the lower right corner>15
Please enter the y coordinate of the lower right corner>15
Please enter the x coordinate of the upper left corner>12
Please enter the y coordinate of the upper left corner>12
Please enter the x coordinate of the lower right corner>20
Please enter the y coordinate of the lower right corner>20
The intersection of these two rectangles is the rectangle: java.awt.Rectangle[x=12,y=12,width=13,height=13]
The union of these two rectangles is the rectangle: java.awt.Rectangle[x=10,y=10,width=22,height=22]
Do you want to study two more rectangles>
at this line:
Quote
Do you want to study two more rectangles>
The console will not accept my input.
I don't see the problem.

New Topic/Question
Reply




MultiQuote






|