|
|
#1 (permalink) |
|
Silver Member
![]() Join Date: Sep 2005
Age: 21
Posts: 114
|
I need to finish this program as soon as possible and i am having trouble. The specification is to Write a Java program named lab32. The program gets the length and the width of a rectangle from the user, calculates the area and displays result. Create, compile and test the program using jGRASP compiler.
import javax.swing.*; public class lab4 { public static void main(String [] args) { double area; double length; double width; //Declare three variables named length, width and area of type double double length, _____width_____, _____length_______; //Declare a String object String s; //Input the length using showInputDialog s = JOptionPane.showInputDialog(“Enter the length:”); //Convert the length input to double length = Double.parseDouble(s); //Input the width using showInputDialog _________________________________ //Convert the width input to double __________________________________ //Calculate the area __________________________________ //Display the length, width and area System.out.println("Length: " + length); //Display the Width ____________________________ //Display the area ____________________________ System.exit(0); }//close main }//close the class Sample output |
|
|
|
|
|
#2 (permalink) |
|
Bronze Member
![]() Join Date: May 2006
Posts: 30
|
import java.io.*;
public class lab32 { public static void main(String [] args) { double area; double length; double width; String s; BufferedReader stdin = new BufferedReader( new InputStreamReader( System.in ) ); s=stdin.readLine(); length = Double.parseDouble(s); s=stdin.readLine(); width = Double.parseDouble(s); area=length*width; System.exit(0); } }
__________________
My Rig [Zangetsu]: Cpu:AMD Athlon X2 5600+ OverClocked @3150 mhz MoBo:Gigabyte GA-MSLI55-s4 Memory:4GB DDRII 667 mhz Overclocked @ 725 mhz Gpu:XFX Geforce 8800 GTS XXX Edition ( 320 mb videoram) HDD(s):160gb WD,160gb WD & Seagate 7200.10 250 gb |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Java Programming - Need URGENT help with CITY JUMPER - Java Programming | shariq | Computer Games and Consoles | 0 | 01-19-2007 07:05 AM |
| System Alert!! Fake! Re: anti-vermins.com | J_D | Computer Security | 5 | 01-07-2007 12:36 PM |
| Java Problems | Hobo_man | Operating Systems | 1 | 03-03-2006 06:47 PM |
| Database Organizer Program Thingy | Gwarnokyon | General Software | 2 | 02-26-2006 08:12 PM |
| Help, can't remove program or sys restore, causing problems | Nooyawkah | General Software | 1 | 11-06-2005 10:32 AM |