Results 1 to 7 of 7
  1. #1
    AgentZero is offline Member
    Join Date
    Sep 2008
    Posts
    3
    Rep Power
    0

    Default im new and need help

    ok this is the demo and i need help writing the the class
    Java Code:
    import java.util.Scanner;
    // test driver for the Bottle class
    public class BottleDemo
    {
    public static void main(String[] args)
    {
    Scanner scan = new Scanner(System.in);
    int x;
    Bottle bottle1 = new Bottle();
    Bottle bottle2 = new Bottle();
    Bottle bottle3 = new Bottle();
    Bottle bottle4 = new Bottle();
    Bottle bottleAve = new Bottle();
    System.out.println("please enter a number for bottle1:");
    bottle1.read();
    System.out.println("bottle1 is this value " + bottle1);
    System.out.println("please enter a number for bottle2:");
    bottle2.read();
    System.out.println("please enter a number for bottle3:");
    bottle3.read();
    System.out.println("please enter a number for bottle4:");
    bottle4.read();
    bottleAve = bottleAve.add(bottle1);
    bottleAve = bottleAve.add(bottle2);
    bottleAve = bottleAve.add(bottle3);
    bottleAve = bottleAve.add(bottle4);
    bottleAve = bottleAve.divide(4);
    System.out.println("the average of the 4 bottles is: " + bottleAve);
    if (bottle1.equals(bottle3))
    {
    System.out.println("bottle1 and bottle3 are equal");
    }
    else
    {
    System.out.println("bottle1 and bottle3 are not equal");
    }
    System.out.println("Eenter an integer to add to bottle 1");
    x = scan.nextInt();
    bottle1.add(x);
    System.out.println("adding your number " + x +
    " to bottle1 gives " + bottle1);
    bottle2 = bottle1.add(bottle3);
    System.out.println("adding the number “ + bottle3 + “ from bottle3 to bottle1 gives " + bottle2);
    }
    }
    can ppl help. Thanks

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You may want to specify better exactly what you need help with. "i need help writing the the class" doesn't tell us what you've done that works, that doesn't work, what is still missing or anything specific.

    Good luck.

  3. #3
    AgentZero is offline Member
    Join Date
    Sep 2008
    Posts
    3
    Rep Power
    0

    Default

    I need help writing the class Bottle

    I dunno how to start. ive need alot work and help.
    Java Code:
    import java.util.Scanner;
    public class Bottle
    {
    private String Bottle; 
    public void readName( )
    {

  4. #4
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Is this a beer bottle? ;)

    Java Code:
    import java.util.Scanner;
    public class Bottle
    {
            private String Bottle; 
            Scanner scan=new Scanner(System.in);
            private int numOfbottle=0;
            public void read( )
            {
                numOfBottle=scan.nextInt();
             }
            public int getNumOfbottle(){
                 return this.numOfBottle;
             }

  5. #5
    AgentZero is offline Member
    Join Date
    Sep 2008
    Posts
    3
    Rep Power
    0

    Default

    i could use one right about now!

    soooooooo.....

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    This question has been cross-posted everywhere from here to héll and gone. To the original poster:

    Please do not cross-post questions in multiple forums. This will frustrate anyone who tries to help you only to find out later that the same answer was given hours ago in a cross-posted thread. For this reason, many volunteers here and at the other sites refuse to help repeat offenders.

  7. #7
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Quote Originally Posted by Fubarable View Post
    This question has been cross-posted everywhere from here to héll and gone. To the original poster:
    Man you rock as usually with the posts. :D

Posting Permissions

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