Results 1 to 1 of 1
Thread: How do I end this program?
- 01-28-2012, 07:57 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 1
- Rep Power
- 0
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
-
How to code a program to send messages to a chat program?
By josh2992 in forum New To JavaReplies: 2Last Post: 04-02-2011, 12:57 PM -
How would I open a program from a single button of another program. Help...
By decgaid06 in forum New To JavaReplies: 13Last Post: 03-22-2011, 06:49 AM -
changing my program to array working program
By Chewart in forum New To JavaReplies: 39Last Post: 11-18-2009, 06:53 PM -
How to execute an External Program through Java program
By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 02:40 PM -
How to execute an External Program through Java program
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks