Results 1 to 3 of 3
  1. #1
    fresh83 is offline Member
    Join Date
    Dec 2009
    Posts
    55
    Rep Power
    0

    Default No errors but, nothing in console ..?

    Java | public class BeerSong{ publ - BeerSong - 9KppyJBu - Pastebin.com


    Check it out, its pretty simple code, im self teaching myself and i cant seem to figure out why when i run it its just a infinite hourglass.

  2. #2
    Vorfin's Avatar
    Vorfin is offline Member
    Join Date
    Jul 2010
    Location
    Near London.
    Posts
    7
    Rep Power
    0

    Default

    You've closed your While Loop before your second If. It should be like:

    Java Code:
    public class BeerSong {
      
    	public static void main (String[] args){
        
    		int BeerNum=20;      
    		String word ="bottles";
     
    		while(BeerNum>0) {
    			if (BeerNum==1) {
    				word = "bottle";
    			}		
    		
    			if(BeerNum>0) {
    				System.out.println(BeerNum+word+"of beer on the wall");
    				System.out.println(BeerNum+word+"bottles of beer");
    				System.out.println("take one down ,pass it around");
    				System.out.println(BeerNum+word+"of beer on the wall");
    				BeerNum=BeerNum-1;
    			} else { 
    				System.out.println("no more beer bitch");
    				System.out.println("go home");
    			}  
    		}
    	}
    }

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

Similar Threads

  1. In-game console
    By Mr.Beans in forum New To Java
    Replies: 5
    Last Post: 08-17-2009, 11:22 PM
  2. Replies: 3
    Last Post: 03-08-2009, 02:51 AM
  3. Java console
    By johnjw in forum New To Java
    Replies: 5
    Last Post: 11-28-2008, 01:45 PM
  4. Console doesn't appear!
    By PeteMarsh in forum New To Java
    Replies: 2
    Last Post: 12-17-2007, 06:41 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
  •