ComputerForum.com ComputerForum.com  
Go Back   Computer Forum > General Chat > Off Topic Chat

Reply
 
LinkBack Thread Tools Display Modes
Old 07-21-2008, 05:31 PM   #1 (permalink)
Silver Member
 
Join Date: Sep 2005
Age: 21
Posts: 114
Default Can someone help me with java program

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
alyoob is offline   Reply With Quote


Old 07-21-2008, 06:21 PM   #2 (permalink)
Bronze Member
 
Abkrino's Avatar
 
Join Date: May 2006
Posts: 30
Default

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
Abkrino is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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

All times are GMT +1. The time now is 02:43 AM.


Powered by: vBulletin Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
Copyright © 2002-2008 Computer Forum and Web Design Forum