Results 1 to 8 of 8
- 10-08-2008, 04:39 AM #1
Member
- Join Date
- Sep 2008
- Posts
- 58
- Rep Power
- 0
java.util.UnknownFormatConversionException error
Why do I get this error?
Java 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
- 10-08-2008, 06:04 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Invalid conversion in your code. Double check it. Can you show your conversion here to see.
- 10-08-2008, 02:51 PM #3
Can you show the printf at line 55?at Maclaurin1.main(Maclaurin1.java:55)
- 10-08-2008, 06:04 PM #4
Member
- Join Date
- Sep 2008
- Posts
- 58
- Rep Power
- 0
Heres the snippet of the code that asks to print:
Java 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); }
- 10-08-2008, 06:07 PM #5
I see more than one printf.
Which one is causing the error?
- 10-08-2008, 06:11 PM #6
Member
- Join Date
- Sep 2008
- Posts
- 58
- Rep Power
- 0
The errors are coming from the last 4 lines.The rest of the functions are getting executed. Im getting results if I dont include the last 4 lines.
- 10-08-2008, 06:23 PM #7
Can you post THE LINE that causes the error?
With the error message.
Have you tried debugging your code? Try printing the values WITHOUT formatting.
Can the value of result be NaN?Last edited by Norm; 10-08-2008 at 06:27 PM.
- 10-09-2008, 04:15 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
And what's the data type of variable result. I cannot find there declaration in your code segment.
Similar Threads
-
java.util
By Java Tutorial in forum Java TutorialReplies: 1Last Post: 02-07-2008, 01:46 PM -
Using java.util.Stack
By Java Tip in forum Java TipReplies: 0Last Post: 11-20-2007, 05:17 PM -
Using java.util.Formatter
By Java Tip in forum Java TipReplies: 0Last Post: 11-16-2007, 02:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks