Results 1 to 1 of 1
  1. #1
    jon1902 is offline Member
    Join Date
    Jan 2012
    Posts
    1
    Rep Power
    0

    Default 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?

    Java 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

    Java 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"); 
    
    } 
    }
    Last edited by jon1902; 01-28-2012 at 08:24 PM.

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2011, 12:57 PM
  2. Replies: 13
    Last Post: 03-22-2011, 06:49 AM
  3. changing my program to array working program
    By Chewart in forum New To Java
    Replies: 39
    Last Post: 11-18-2009, 06:53 PM
  4. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  5. Replies: 0
    Last Post: 10-04-2007, 09:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •