Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
Beer song HomeWork
Tariq Ab
Greenhorn
Posts: 14
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I just have a quick question.
I'm writing this application to view the Beer Song (Song)
The output I'm getting is perfect, but the only thing wrong is that it starts from 74 not 99?!!!
here is my code:
public class Song { public static void main (String[] args) { int beernum = 99; String word = "bottles"; while ( beernum > 0) { System.out.println ( beernum + " " + word + " of beer on the wall"); System.out.println (beernum + " " + word + " of beer"); System.out.println ("Take one down."); System.out.println ("pass it around"); beernum = beernum - 1; } if (beernum == 1) { word = "Bottle"; } if (beernum == 1) { System.out.println ( beernum + " " + word + " of beer on the wall"); } else { System.out.println ("No more bottles of beer on the wall"); } } }
Greg Brannon
Bartender
Posts: 563
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I believe 75 - 99 appear "off the top" of your display area or in excess of your console buffer size.
Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Tariq Ab
Greenhorn
Posts: 14
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Great!
I'm glad its just not my fault.
Thank you
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Head First Java - Beer question
Head first Beersong
Why does this program start from 60 bottles of Beer and not 99
Beersong
Back Again with a program...
More...