This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Howdy...Nice board ya got here OK. I am working on a program for class and I cant get my double variable to properly format as a percent. We were told to use the NumberFormat class and the getPercentInstance method. This is what I am using now and it keeps truncating the decimal portion of my number. Here is my code:
I am guessing there is just something simple that I am missing here [ February 19, 2002: Message edited by: Zach Spoelstra ]
Do you have access to the API documentation? (Javadocs)? If so, you could just look up the NumberFormat class and see the API methods there and probably solve this problem yourself. I just looked it up really quickly and there are two methods that might be useful: NumberFormat.setMaximumFractionDigits(int); NumberFormat.setMinimumFractionDigits(int);
Hope this helps!
Joined: Feb 19, 2002
Actually I have looked extensively at the API and I couldn't for the life of me figure out how to use some of those. I'll give them a shot and report back. Thanks