Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

print as currency  RSS feed

 
Zach Ellerbrook
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've brain-farted and my reference books are not with me until Sunday. How do you print a type double in currency format? ex. print 14.50 instead of 14.5
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Zach,

public class DemoCurrency {

public static void main(String ... args) {
System.out.printf("%.2f",12.23);
}
}

or


Thanks and Regards,
cmbhatt
[ April 06, 2007: Message edited by: Chandra Bhatt ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!