I am new to Java and I have project due where I need to display the objects of an Array (inventory list) in a GUI one product at a time. I have everything functioning the way I need to other than I can not figure how to return the double values in dollar and cent format, I get too many decimal places.
I have been over the text book chapters several times and cannot find one example that sheds any light on this issue, in fact the text book has been less than helpful on this entire GUI project.
I have attached a zip file that contains all of my classes. Where I am having difficulty is on lines 177,178,180,181, and 183 of the DVDdisplay class.
I have tried to import the Currency Utility and change my String.format() to currency.format() and this returns a GUI void of any array info. I would greatly appreciate any suggestions that anyone may have.
1 Replies - 195 Views - Last Post: 29 November 2011 - 09:31 PM
#1
Trying to display values from an array in a GUI in Currency format
Posted 29 November 2011 - 09:13 PM
Replies To: Trying to display values from an array in a GUI in Currency format
#2
Re: Trying to display values from an array in a GUI in Currency format
Posted 29 November 2011 - 09:31 PM
Try the String class format() method something like
double amount = 3.14159;
String str = String.format("Amount: $ %5.2f", amount);
sould put in str "Amount: $ 3.14"
double amount = 3.14159;
String str = String.format("Amount: $ %5.2f", amount);
sould put in str "Amount: $ 3.14"
This post has been edited by pbl: 29 November 2011 - 09:31 PM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|