How do I end this program?
I need it to end up like this this below. I need it to end at the width or the height being 0. What can I do to make this happen?
Code:
First corner X coordinate:
100
First corner Y coordinate:
100
Second corner X coordinate:
100
Second corner Y coordinate
100
Width: 0 Height: 0 Area: 0
finished
Code:
import java.util.Scanner;
class areasofrectangles
{
public static void main (String[] args )
{
Scanner scan=new Scanner( System.in );
int a, b, c, d;
int area, height, width;
System.out.print ("First corner X coordinate: ");
a = scan.nextInt ();
while (!( a ==0))
{
System.out.print ("First corner Y coordinate: ");
b = scan.nextInt ();
System.out.print ("Second corner X coordinate: ");
c = scan.nextInt ();
System.out.print ("Second corner Y coordinate: ");
d = scan.nextInt ();
width = Math.abs(c - a);
height = Math.abs(d - b);
area = width * height;
System.out.println ("Width: " + width + " Height: " + height + " Area: " + area);
System.out.println ();
System.out.print ("First X Coordinate: ");
a = scan.nextInt ();
}
System.out.println ("Finished");
}
}