Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Percentages displayed

 
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
 
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.
 
Author
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
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.
 
Your mother was a hamster and your father was a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic