java - why does my numbers no show up when I run my codes -


you’re going automate famous song “99 bottles of xxx on wall”. print lyrics of 99 verses of song. use loop! if don’t know lyrics, them google.

the program should:

  • ask user age

  • if user 21 or older, ask them if prefer beer or soda

    a. if under 21 or prefer soda, lyrics “99 bottles of soda on wall”

    b. if on 21, “99 bottles of beer”

  • you must use while loop , counter variable must part of print statement!

  • so first verse be:

    99 bottles of soda on wall

    99 bottles of soda

    if 1 of bottles should fall off wall

    …..98 bottles of soda on wall

  • the last verse:

    1 bottle of soda on wall

    1 bottle of soda

    if lone bottle of soda should fall off wall

    no bottles of soda on wall!

so think, need add loop print last verse different lyrics?

// here code. when run number of bottles start 12, not 99 how fix this??

scanner user = new scanner(system.in);             int age, beverage;              system.out.println("please type in age");            age = user.nextint();             user.nextline();            system.out.println("would soda or beer? soda=1 beer=2");            beverage = user.nextint();          if(age<21 || beverage==1)            {            int bottles = 99;             while( 1< bottles){                 system.out.println(bottles+" of soda on wall");                 system.out.println(bottles+" bottles of soda");                 system.out.println("if 1 of bottles should fall off wall");                 bottles--;                 system.out.println("..."+bottles+" bottles of soda on wall");             if(bottles==1){                 system.out.println(bottles+" of soda on wall");                 system.out.println(bottles+" bottles of soda");                 system.out.println("if lone bottle of soda should fall off wall");                 system.out.println("no bottles of soda on wall");             }         }     }         if(age>=21 && beverage == 2)         {             int bottles=99;             while(1< bottles){                 system.out.println(bottles+" of beer on wall");                 system.out.println(bottles+" bottles of beer");                 system.out.println("if 1 of bottles should fall off wall");                 bottles--;                 system.out.println("..."+bottles+" bottles of beer on wall");             if(bottles==1){                 system.out.println(bottles+" of beer on wall");                 system.out.println(bottles+" bottles of beer");                 system.out.println("if lone bottle of beer should fall off wall");                 system.out.println("no bottles of beer on wall");             }         }     }          }     } 

your code does start printing 99 bottles. if see last 12 bottles, there's issue output console. try scrolling further up, or try different console, or try redirecting file (add " > output.txt" command line call , check content of ouput.txt).


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -