Results 1 to 2 of 2
  1. #1
    FAkamo is offline Member
    Join Date
    Oct 2011
    Posts
    6
    Rep Power
    0

    Default Using printf without specifiers

    1st post here as a member on this forums, so pardon me if somethings wrong with my post or offensive to anyone. But below is my code for my HW assignment due in a little while.

    My question is how do I go about using the printf method without specifiers??

    Also if someone would be helpful enough to just take a quick look at my code just to make sure everythings good (For some reason I keep getting a unclosed string literal at the System.out.printf and as well as a ")" expected at the increment ++months) I'd really appreciate it. Thanks.

    Java Code:
    /*
     *
     *Code a do/while loop that only prints the name of the month from September through November or it issues a 
     *"Month not found!" error message.  Use if/else statements.  A variable called month has been declared and 
     *initialized to 9.  Use printf() without specifiers.  Code using Notepad. 
     * Save as YourLastNameFirstInitialDoWhileHW.txt
     *
     *
    
    */
    
    
    public class doWhileLoopHW
    {
    	
    	public static void main ( String[] args)
    	{
    		
    		int months = 9;
    		
    		do
    		{
    		
    			System.out.printf( "%d , months );
    			++months;
    		
    		
    		} while ( months <= 2); //END do...while 
    		
    		if ( months >= 3)
    		{
    			System.out.println( "Month not found!" );
    			
    		
    		} else System.out.printf( "%d" , months );
    		
    	
    	
    	
    	
    	
    	
    	}//END Main
    	
    	
    }//END Class doWhileLoopHW
    Last edited by JosAH; 10-17-2011 at 08:58 AM. Reason: added [code] ... [/code] tags

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: Using printf without specifiers

    System.out.printf( "%d , months );
    vs
    System.out.printf( "%d" , months );

    :D

Similar Threads

  1. Access Specifiers
    By maheshpwr in forum New To Java
    Replies: 7
    Last Post: 03-17-2011, 09:54 AM
  2. printf
    By razzle in forum New To Java
    Replies: 4
    Last Post: 11-12-2010, 02:13 PM
  3. Format Specifiers
    By Cass29 in forum New To Java
    Replies: 3
    Last Post: 12-20-2009, 03:49 PM
  4. Printf error
    By ks1615 in forum New To Java
    Replies: 4
    Last Post: 03-10-2009, 06:59 AM
  5. printf
    By Jack in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 04:31 AM

Posting Permissions

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