Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 2 FirstFirst 12
Results 26 to 34 of 34

Thread: Why isn't this code working?

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Why isn't this code working?

    Let us know when you have wrapped your code in code tags.

  2. #27
    Member
    Join Date
    Feb 2012
    Posts
    47
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Why isn't this code working?

    Quote Originally Posted by Norm View Post
    Let us know when you have wrapped your code in code tags.
    That's the problem I don't know. I'm new to this forum and I'm not sure how to do it. So you just want me to quote my code I'm guessing?

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Why isn't this code working?

    Edit your post and wrap your code with
    [code=java]

    <YOUR CODE HERE>

    [/code]
    to get highlighting

  4. #29
    Member
    Join Date
    Feb 2012
    Posts
    47
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Why isn't this code working?

    Quote Originally Posted by Norm View Post
    Edit your post and wrap your code with
    [code=java]

    <YOUR CODE HERE>

    [/code]
    to get highlighting
    Thank you. Better now?

  5. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Why isn't this code working?

    Yes, the formatting is better, but there are Way too many empty lines!!!

    Can you explain what is wrong with the program's output. You've posted two outputs but didn't explain what was wrong with either of them in a clear way. Please explain what you want to be changed.

    You need to add the -Xlint option for the compiler to see the possible error.
    Last edited by Norm; March 12th, 2012 at 03:09 PM.

  6. #31
    Member
    Join Date
    Feb 2012
    Posts
    47
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Why isn't this code working?

    Quote Originally Posted by Norm View Post
    Yes, the formatting is better, but there are Way too many empty lines!!!

    Can you explain what is wrong with the program's output. You've posted two outputs but didn't explain what was wrong with either of them in a clear way. Please explain what you want to be changed.
    Oh ok. Um I just need the output to say:

    Ninety Nine bottles of beer on the wall,
    Ninety Nine bottles of beer,
    Take one down, pass it around,
    Ninety eight bottles of beer on the wall.

    Ninety eight bottles of beer on the wall,
    Ninety eight bottles of beer,
    Take one down, pass it around,
    Ninety seven bottles of beer on the wall.

    The problem is that the numbers aren't going down. It's just repeating ninety nine the entire time. However, it shows a number before the whole phrase like:

    ninety nine
    ninety nine bottles of beer on the wall,
    Ninety Nine bottles of beer,
    Take one down, pass it around,
    Ninety Nine bottles of beer on the wall.

    ninety eight
    Ninety Nine bottles of beer on the wall,
    Ninety Nine bottles of beer,
    Take one down, pass it around,
    Ninety Nine bottles of beer on the wall.

    I need the phrase itself to repeat while going down by 1 each time (i.e. seventy seven bottles of beer on the wall, take one down pass it around, seventy six bottles of beer on the wall). That's the problem.

  7. #32
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Why isn't this code working?

    For testing change the number of bottles to 19 and see what is output.

    You need to add the -Xlint option for the compiler to see the possible error.

  8. #33
    Member
    Join Date
    Feb 2012
    Posts
    47
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Why isn't this code working?

    What number of bottles?

    There is no error. It's just the wrong code.

  9. #34
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Why isn't this code working?

    What number of bottles?
    BottleSong bs = new BottleSong(19); //<<<<<<<<< small number for testing

    There could be an error in your logic. The option will show it.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. I don't get why this code isn't working
    By tai8 in forum What's Wrong With My Code?
    Replies: 23
    Last Post: February 20th, 2012, 12:38 PM
  2. Code working only on ide
    By xeyos in forum Java Networking
    Replies: 0
    Last Post: November 17th, 2011, 05:40 PM
  3. Simple code, cant get it working.
    By Malmen in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 8th, 2011, 03:28 PM
  4. My code is not working
    By mike2452 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 9th, 2011, 06:17 AM
  5. Getting code working with gui
    By Nostromo in forum AWT / Java Swing
    Replies: 2
    Last Post: March 21st, 2011, 09:34 PM