• 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

is there a way to format multiple strings with one variable?  RSS feed

 
Ranch Hand
Posts: 423
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a load of strings with floats and ints that need to be formatted to 2 decimal places and moved across the screen

i know that this line formats subTotal to 2 decimal places


is there a way you can use a variable like this


and apply it to multiple variables?

i tried a few things but just got errors

or does this line have to be applied to every line you want to format

like:





 
jon ninpoja
Ranch Hand
Posts: 423
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also is there a way to add a currency symbol like $ or € to the format so that it puts it before the float
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!