public class TryMyMath {
public static void main(String args[])
{
double num = Math.E;
printTable(num);
}// end main
public static void printTable(double num){
int n = 1;
for(n = 1;n <= 10; n++)
{
num = Math.pow(num, n);
System.out.printf("%d %lf", n, num);
}
round100th(num);
}
public static double round100th(double num)
{
return Math.round(num*100.)/100.0 ;
} // end round100th
}
i have this question with using printf in java, so this is the error i get with printf
Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = 'l'
at java.util.Formatter$FormatSpecifier.conversion(Unknown Source)
at java.util.Formatter$FormatSpecifier.<init>(Unknown Source)
at java.util.Formatter.parse(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.io.PrintStream.format(Unknown Source)
at java.io.PrintStream.printf(Unknown Source)
at TryMyMath.printTable(TryMyMath.java:15)
at TryMyMath.main(TryMyMath.java:7)
when i take out printf statement there wasn't any error, am I not using printf the right way it is supposed to be used in java?
and also i'm new to java and eclipse so i don't know what those error mean.
so this is the out put that i get
1 2.7182822 7.3890563 403.4287934 26489122129.8434375 13041808783936237000000000000000000000000000000000000.0000006 Infinity7 Infinity8 Infinity9 Infinity10 Infinity
the output is only right up to n = 3 i don't see anything wrong with the for loop why is this happen?
nvm i saw what wrong with it