Results 1 to 3 of 3
  1. #1
    lala is offline Member
    Join Date
    Oct 2010
    Posts
    80
    Rep Power
    0

    Default Formatting Issue

    Hi again. I am still working on the While loop, but this is a different problem in the loop.
    Many thanks to everyone, pbrockway2, Jos.

    I'm getting there and LEARNING(mmmm what a concept).

    I've hit a snag. Variable monIntR is displayed as 0.0060. I want it to look like 0.006. So I used the System.out.printf statement and the compiler screamed bloody murder.
    Error Message:
    The monthly interest is Exception in thread "main" java.util.MissingFormatArgumentException: Format specifier '.3f'
    at java.util.Formatter.format(Formatter.java:2432)
    at java.io.PrintStream.format(PrintStream.java:920)
    at java.io.PrintStream.printf(PrintStream.java:821)
    at Monthly_Test.main(Monthly_Test.java:24)


    Java Code:
    monIntR = (inRateyr / 12)/ 100 ;
    System.out.printf("The monthly interest is %.3f  : " + monIntR);
    I changed the code to add the variable inside the quotes:

    Java Code:
    System.out.printf("The monthly interest is monIntR = %.3f   : " + monIntR);
    but the compiler is still unhappy. I Googled the error message and one of the answers was "This means that you didn't specify something to be formatted for the second specifier. "

    I went to java2s.com, but I'm still stumped. Do I need some type of pre-defined method???

    Thank you

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

    Default

    Java Code:
    System.out.printf("The monthly interest is %.3f ", monIntR);

  3. #3
    lala is offline Member
    Join Date
    Oct 2010
    Posts
    80
    Rep Power
    0

    Default Formatting issue (SOLVED)

    Thank you eRaaaa. I found my error right after your response.
    lala

Similar Threads

  1. Date formatting
    By bikkerss in forum New To Java
    Replies: 13
    Last Post: 05-08-2010, 04:07 PM
  2. Formatting String
    By ersachinjain in forum Advanced Java
    Replies: 13
    Last Post: 10-21-2009, 09:26 PM
  3. formatting..
    By sireesha in forum New To Java
    Replies: 16
    Last Post: 06-26-2009, 07:11 PM
  4. Formatting a toString
    By MooNinja in forum New To Java
    Replies: 8
    Last Post: 03-31-2009, 07:32 PM
  5. formatting String
    By bugger in forum New To Java
    Replies: 1
    Last Post: 11-16-2007, 07:27 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
  •