Tuesday, October 13, 2009

[Java] Re: Please hep me writing my first java program!!

 


import javax.swing.*;
public class First
{

public static void main(String args[])
{
House house = new House();
Yard yard = new Yard();

house.length = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter the house length"));
house.width = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter the house width"));
house.area = house.length * house.width;

yard.length = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter the yard length"));
yard.width = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter the yard width"));
yard.area = house.area - (yard.length * yard.width);

// I don't understand the formula
// timecutting = yard.area / 2.3

JOptionPane.showMessageDialog(null, "Yard Length: "+yard.length +"\nYard width: "+yard.width +"\nYard Area: " +yard.area +"\nHouse Length: "+house.length +"\nHouse width: "+house.width +"\nHouse Area: " +house.area);
//okay, just fix the rest!
}
}

class House
{
int length;
int width;
int area;
int timecutting;
public House()
{
length = 0;
width = 0;
area = 0;
timecutting = 0;
}
}
class Yard
{
int length;
int width;
int area;
public Yard()
{
length = 0;
width = 0;
area = 0;
}
}

tdtech.co.cc
--- In Java_Official@yahoogroups.com, Preyas Patel <patelpreyasi@...> wrote:
>
> Q. Write a Java program that reads in the length and width of a rectangular yard and the length and the width of a rectangular house situated in the yard. Your program should compute the time required (In minutes) to cut the grass at the rate of 2.3 square meters a second.
> Output Format:
> Yard Length: ________
> Yard width: _________
> Yard Area: ________
> House Length: ________
> House Width: ________
> House Area: _________
> Grass Area: __________
> Cutting Time: ________
>
> The above is the question of my assignment and I have came up with below algorithm.
> 1 Input the length of yard
> 2 Input the width of yard
> 3 Input the length of house
> 4 input the width of the house
> 5 Area of the House ß Length of the house * Width of the house
> 6 Area of the Yard ß Area of the house â€" (Length of the yard * Width of the yard)
> 7 Time Required cutting the grass ß Area of yard/2.3 m. square/sec/60
> 8 Print Times
>
> I tried really hard to write program but I don’t know I am having problem and I can’t get it correct. Well this is my first ever java assignment so I found it little hard for me. So if you please can help me writing the program.
>
> Regards, --------------
> Preyas Patel
> B.S. Computer Science
> California State University, Northridge
> + 1 619 200 4818
> patelpreyasi@...
> patelpreyas2@...
>
>
> From cricket scores to your friends. Try the Yahoo! India Homepage! http://in.yahoo.com/trynew
>
> [Non-text portions of this message have been removed]
>

__._,_.___
Visit http://aiaiai.com or http://jgame.org for more groups to join.
Java Official Group is created for the following topics: Java 2 Enterprise Edition - J2EE, Java 2 Standard Edition - J2SE, Java 2 Micro Edition - J2ME, XML, XSL, XSD, XPATH, Web Services, Jini, JXTA for all type of Java Geeks.
Whoever posts spam / ads / job related message will be BANNED IMMEDIATELY
Recent Activity
Visit Your Group
Give Back

Yahoo! for Good

Get inspired

by a good cause.

Y! Toolbar

Get it Free!

easy 1-click access

to your groups.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___

No comments:

Post a Comment