Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Percentages displayed

 
Collin Grey
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

how do I show the percentages of items counted in my results pannel?

Eg.

I would like to display the following, obviously variable depending on results:
12.5% Blue
12.5% Grey
25.0% Silver
50.0% Gold

But it only displays:
Blue
Grey
Silver
Gold

Any ideas?

Collin
 
Darin Niard
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You haven't provided us with enough information. What is your specific problem, what errors are you getting, etc.
 
James Chegwidden
Author
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Post your code. We are able to help more if we see what you have (not just verbal description?

2.To get an instance of a class to format numbers in a currency or as a percentage, use the statement


f= NumberFormat.getCurrencyInstance(getLocale());
or


f= NumberFormat.getPercentInstance(getLocale());

Do you know how to use these?
 
James Chegwidden
Author
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is another example to help:



The output from this program is:

47%
 
Collin Grey
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I will try it.
 
Collin Grey
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I will try it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic