java homework


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: java homework

Hybrid View

  1. #1
    Mona Guest

    java homework


    Hi, i'm a student and i have a homework about java i will attach the question
    to my message if u can help me in solving the problem.

    Question-1:
    a. Define a class called Box with the following members:

    · Data members length, width and height
    · A no – parameters constructor.
    · A constructor that takes parameters to initialize the data members
    · ‘set’ Methods that will set the value of a particular data member to a
    specific value received as a parameter.
    · ‘get’ Methods that will return the value of a particular data member
    · A Volume( ) method to calculate and return the volume of a Box.

    b. Define a class TestBox with a main( ) method.

    In the main( ) method of TestBox, create an instances of Box using each of
    the constructors (no- parameters constructor and parameters-constructor)
    Use the Volume method to calculate the volume of each box.
    Allow the user to input new values for the length width and height of one
    of the boxes.
    (Call the set Methods to assign the new values to the data members).
    Call the Volume( ) method to calculate the new volume of the box.
    Display the new volume of the box


    that all if u can help me in my homework.





  2. #2
    mona Guest

    Re: java homework


    "Mona" <mona941406@yahoo.com> wrote:
    >
    >Hi, i'm a student and i have a homework about java i will attach the question
    >to my message if u can help me in solving the problem.
    >
    >Question-1:
    >a. Define a class called Box with the following members:
    >
    >· Data members length, width and height
    >· A no – parameters constructor.
    >· A constructor that takes parameters to initialize the data members
    >· ‘set’ Methods that will set the value of a particular data member to a
    >specific value received as a parameter.
    >· ‘get’ Methods that will return the value of a particular data member
    >· A Volume( ) method to calculate and return the volume of a Box.
    >
    >b. Define a class TestBox with a main( ) method.
    >
    >In the main( ) method of TestBox, create an instances of Box using each

    of
    >the constructors (no- parameters constructor and parameters-constructor)
    >Use the Volume method to calculate the volume of each box.
    >Allow the user to input new values for the length width and height of one
    >of the boxes.
    >(Call the set Methods to assign the new values to the data members).
    >Call the Volume( ) method to calculate the new volume of the box.
    >Display the new volume of the box
    >
    >
    >that all if u can help me in my homework.
    >i need it tommorrow.

    thanks.
    >
    >
    >



  3. #3
    james Guest

    Re: java homework


    "Mona" <mona941406@yahoo.com> wrote:
    >
    >Hi, i'm a student and i have a homework about java i will attach the question
    >to my message if u can help me in solving the problem.
    >
    >Question-1:
    >a. Define a class called Box with the following members:
    >
    >· Data members length, width and height
    >· A no – parameters constructor.
    >· A constructor that takes parameters to initialize the data members
    >· ‘set’ Methods that will set the value of a particular data member to a
    >specific value received as a parameter.
    >· ‘get’ Methods that will return the value of a particular data member
    >· A Volume( ) method to calculate and return the volume of a Box.
    >
    >b. Define a class TestBox with a main( ) method.
    >
    >In the main( ) method of TestBox, create an instances of Box using each

    of
    >the constructors (no- parameters constructor and parameters-constructor)
    >Use the Volume method to calculate the volume of each box.
    >Allow the user to input new values for the length width and height of one
    >of the boxes.
    >(Call the set Methods to assign the new values to the data members).
    >Call the Volume( ) method to calculate the new volume of the box.
    >Display the new volume of the box
    >
    >
    >that all if u can help me in my homework.
    >
    >
    >
    >



  4. #4
    james Guest

    Re: java homework


    "james" <j-lewis@satx.rr.com> wrote:
    >
    >"Mona" <mona941406@yahoo.com> wrote:
    >>
    >>Hi, i'm a student and i have a homework about java i will attach the question
    >>to my message if u can help me in solving the problem.
    >>
    >>Question-1:
    >>a. Define a class called Box with the following members:
    >>
    >>· Data members length, width and height
    >>· A no – parameters constructor.
    >>· A constructor that takes parameters to initialize the data members
    >>· ‘set’ Methods that will set the value of a particular data member to

    a
    >>specific value received as a parameter.
    >>· ‘get’ Methods that will return the value of a particular data member


    >>· A Volume( ) method to calculate and return the volume of a Box.
    >>
    >>b. Define a class TestBox with a main( ) method.
    >>
    >>In the main( ) method of TestBox, create an instances of Box using each

    >of
    >>the constructors (no- parameters constructor and parameters-constructor)
    >>Use the Volume method to calculate the volume of each box.
    >>Allow the user to input new values for the length width and height of one
    >>of the boxes.
    >>(Call the set Methods to assign the new values to the data members).
    >>Call the Volume( ) method to calculate the new volume of the box.
    >>Display the new volume of the box
    >>
    >>
    >>that all if u can help me in my homework.
    >>
    >>
    >>
    >>

    >public class box{

    private int length;
    private int width;
    private int height;
    public box{}
    public box(int l,int w,int h){
    length=l;
    width=w;
    height=h;}
    public int getLength(){return length;}
    public int getWidth(){return width;}
    public int getHeight(){return height;}
    public int getVolume(){return length*width*height;}
    }
    }there's the box class at least if i have more time I'll help you with the
    main method.
    you may even want to use doubles instead of int

  5. #5
    Join Date
    May 2006
    Posts
    1
    <b> i called the TestBox class finalpractice01</b>

    import java.io.*;

    /*Question-1:
    a. Define a class called Box with the following members:

    · Data members length, width and height
    · A no – parameters constructor.
    · A constructor that takes parameters to initialize the data members
    · ‘set’ Methods that will set the value of a particular data member to a
    specific value received as a parameter.
    · ‘get’ Methods that will return the value of a particular data member
    · A Volume( ) method to calculate and return the volume of a Box.

    b. Define a class TestBox with a main( ) method.

    In the main( ) method of TestBox, create an instances of Box using each of
    the constructors (no- parameters constructor and parameters-constructor)
    Use the Volume method to calculate the volume of each box.
    Allow the user to input new values for the length width and height of one
    of the boxes.
    (Call the set Methods to assign the new values to the data members).
    Call the Volume( ) method to calculate the new volume of the box.
    Display the new volume of the box*/

    public class finalpractice01
    {
    public static void main(String args[]) throws IOException
    {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    Box firstbox = new Box();
    Box secondbox = new Box(10, 10, 10);
    System.out.println("This box's volume is: " + secondbox.Volume());
    System.out.println("Enter new length value ===>>");
    firstbox.setLength(Integer.parseInt(input.readLine()));
    System.out.println("Enger new width value ===>>");
    firstbox.setWidth(Integer.parseInt(input.readLine()));
    System.out.println("Enter new height value ===>>");
    firstbox.setHeight(Integer.parseInt(input.readLine()));
    System.out.println("The new box's volume is: " + firstbox.Volume());
    }

    }

    class Box
    {
    private int length;
    private int width;
    private int height;

    public Box()
    {
    length = 0;
    width = 0;
    height = 0;
    }

    public Box(int l, int w, int h)
    {
    length = l;
    width = w;
    height = h;
    }

    public void setLength(int l)
    {
    length = l;
    }

    public void setWidth(int w)
    {
    width = w;
    }

    public void setHeight(int h)
    {
    height = h;
    }

    public int getLength()
    {
    return length;
    }

    public int getWidth()
    {
    return width;
    }

    public int getHeight()
    {
    return height;
    }

    public int Volume()
    {
    return length *width * height;
    }
    }

  6. #6
    Join Date
    Mar 2006
    Posts
    35
    Hey da7id I don't think the solution is going to help her five years later lol.

  7. #7
    Join Date
    May 2006
    Posts
    22

    Talking

    Maybe she got a deadline extension?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center