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.

Results 1 to 4 of 4

Thread: please help

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question please help

    there is a line in the coding as:
    System.out.printf(" input float(e.g. %5.2f): ", 2.43);

    the output is:

    input float(e.g. 2.43):

    Q:please explain this line completely???????????????

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: please help

    What did the API tell you?

    PrintStream (Java Platform SE 6)
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: please help

    In future, please post in the correct forum. This is the Members Introduction forum..
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  4. #4
    Junior Member madelarbo's Avatar
    Join Date
    Jul 2011
    Location
    Muntinlupa City
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: please help

    i think that is correct output..

    if you can see you put this "%5.2f" which is equivalent into FLOAT..that has 2decimal places
    in C/C++
    if you write that
    it means you have a value to transfer
    like this

    System.out.printf(" input float(e.g. %5.2f): ", 2.43);

    you transfer the value of 2.43 into float..
    thats why the output is

    input float(e.g. 2.43):


    hmm i think that is the explanation.. hmmm..
    you use SYSO thats why they print the output.
    input float(e.g. 2.43):

    like PRINTF /COUT
    -------------------------------
    System.out.printf(" input float(e.g. %5.2f): ", 2.43);
    input float(e.g. 2.43):