Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Printing via the printf function

$
0
0
This is my first time posting, so hello all :)/>/>

I've got some work to do for college, and I've followed the online guides, checked the APIs and even followed my teachers advice ,however, I just can't get this one line to work - it just crashes repeatedly ://>/>

 System.out.printf("Trade Cost: £%.2f ", runningTotal/100); 


runningTotal is an int, and the program would never get to this line without runningTotal equaling well over 100 so I don't see the issue... The error netbeans throws back at me is this:

 Exception in thread "main" java.util.IllegalFormatConversionException: f != java.lang.Integer
	at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4045)
	at java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:2761)
Trade Cost: £	at java.util.Formatter$FormatSpecifier.print(Formatter.java:2708)
	at java.util.Formatter.format(Formatter.java:2488)
	at java.io.PrintStream.format(PrintStream.java:970)
	at java.io.PrintStream.printf(PrintStream.java:871)
	at pdispenser.PDispenser.calculatePrice(PDispenser.java:467)
	at pdispenser.PDispenser.processNewJobDec(PDispenser.java:187)
	at pdispenser.PDispenser.main(PDispenser.java:40)
Java Result: 1 



Please help!! Thanks in advance :)/>/> a pointer in the right direction would be nice :)/>/>

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>