• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Formatting as a percent

 
Zach Spoelstra
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Zach Spoelstra
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic