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: Java error "java.util.UnknownFormatConversionException"

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java error "java.util.UnknownFormatConversionException"

    Why do I get this error?
    Code:

    Exception in thread "main" java.util.UnknownFormatConversionException: Conversio n = '5' at java.util.Formatter.checkText
     
    (Formatter.java:2502) at java.util.Formatter.parse(Formatter.java:2484) at java.util.Formatter.format(Formatter.java:2413) at 
     
    java.io.PrintStream.format(PrintStream.java:920) at java.io.PrintStream.printf(PrintStream.java:821) at Maclaurin1.main(Maclaurin1.java:55) 
     
    Press any key to continue . . .

    All I want to do is convert a number from degrees to radians (Math.toRadians())and find the Math.sin and Math.cos of it


  2. #2
    Junior Member
    Join Date
    May 2008
    Location
    Canada
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java.util.UnknownFormatConversionException error

    Post the code that trows the exception. It seems you use a printf call and the format you are passing is invalid (formats are in the form %something). If you post the code excerpt somebody might point you to the wrong format.
    Daniel @ [www.littletutorials.com]
    Language is froth on the surface of thought

  3. #3
    Junior Member
    Join Date
    Sep 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java.util.UnknownFormatConversionException error

    Heres a snippet of the code:
     	public static void main(String[] args)
     	{
    		double x;
    		x = (Math.PI)/4;
                    double  rad=0;
    		double result=0;
    		System.out.printf("Evaluate x = %1.0f",x);
    		result = sine_evaluate(x);
    		System.out.printf("%nSin Result = %5.15f",result);
    		result = cos_evaluate(x);
    		System.out.printf("%nCos Result = %5.15f%n",result);
    		rad=Math.toRadians(x);
                    result = Math.sin(rad);
                   System.out.printf("%nActual Sine Result = %5.15f%n",result); 
                   result = Math.cos(rad);
                   System.out.printf("%nActual Cos Result = %5.15f%n",result);
     
    	}

  4. #4
    Junior Member
    Join Date
    Apr 2011
    Location
    Pune, India
    Posts
    11
    My Mood
    Cool
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: java.util.UnknownFormatConversionException error

    Hi,

    Can you please put the code for sine_evaluate(x) and cos_evaluate(x);
    Hardik Jadhav

Similar Threads

  1. How to Sort an Array using the java.util.Arrays class
    By JavaPF in forum Java SE API Tutorials
    Replies: 2
    Last Post: May 17th, 2014, 02:16 AM
  2. Replies: 1
    Last Post: December 22nd, 2011, 09:55 AM
  3. How to use an ArrayList and what is its advantage over array?
    By JavaPF in forum Java SE API Tutorials
    Replies: 4
    Last Post: December 21st, 2011, 04:44 AM
  4. Replies: 2
    Last Post: March 23rd, 2010, 02:38 AM
  5. Replies: 4
    Last Post: April 29th, 2009, 11:53 AM