Sum of Exception in thread " main" 0 ' s odd digits: java.util.IllegalFormatConversionException: f != java.lang.Integer at java.util.Formatter$FormatSpecifier.failConversion(Unknown Source) at java.util.Formatter$FormatSpecifier.printFloat(Unknown Source) at java.util.Formatter$FormatSpecifier.print(Unknown Source) at java.util.Formatter.format(Unknown Source) at java.io.PrintStream.format(Unknown Source) at java.io.PrintStream.printf(Unknown Source) at practicebook.sum1.main(sum1.java:86) number /= 10; System.out.printf("Sum of %s' s odd digits: %f " , number, odd_digits_sum); //System.out.printf(" number is " + number); //end main} // end class
What I have tried:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Quote:
Sum of Exception in thread "main" 0's odd digits: java.util.IllegalFormatConversionException: f != java.lang.Integer

Java complain because odd_digits_sum is an integer and %f expect something else.
One can guess that if you look at documentation of printf , you will find how it works.
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •