Results 1 to 3 of 3
  1. #1
    jyde is offline Member
    Join Date
    Oct 2008
    Posts
    13
    Rep Power
    0

    Default Pls i need help with these 2 Java Questions

    1. Describe in detail (i.e., line for line) what the following piece of code does.


    class Cube {
    int side;
    }
    _________________________________________

    class MainCube {

    public static void main(String[] args) {
    Cube c = new Cube();
    c.side = 10;
    System.out.println(“side is “ + c.side);
    }
    }







    2. Circle

     Design a Circle class which is described by the length of its radius

     Design a method that calculates the total surface area of the circle.
    - Equation: Pi * radius * radius

     Design a method that calculates the circumference of the circle.
    - Equation: 2 * Pi * radius

    (Note: Put the design of the class and methods on paper – to be handed up)

     Implement the Circle using a java class, i.e. Circle.java

     Write a MainCircle.java class which

    - Instantiates a new Circle instance,
    - Reads in the length of circle’s radius.
    - Assigns the value of the radius to the instance variable
    - Uses the Circle methods to print the area and circumference to the console.
    - Increases the length of the radius by 10.
    - Uses the Circle methods to print the increased area and circumference to the console.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,449
    Rep Power
    25

    Default

    Sounds like a HW assignment.
    What help are you looking for?
    You provide the answers and we'll grade them.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,244
    Rep Power
    19

Similar Threads

  1. Pls i need help with these 2 Java Questions
    By jyde in forum New To Java
    Replies: 23
    Last Post: 11-11-2008, 05:23 AM
  2. Java Questions...
    By Xarver in forum New To Java
    Replies: 11
    Last Post: 09-20-2008, 05:37 AM
  3. Few Questions about java
    By Grom in forum NetBeans
    Replies: 11
    Last Post: 09-13-2008, 02:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •