Author
Require output to 2 decimal places
Maureen Charlton
Ranch Hand
Joined: Oct 04, 2004
Posts: 218
I'm confused I have just been reading about Implicit Conversions. It states: "If one of the operands is a double then the other operand is converted to a double." So, I have a method: - with the respective getBalance method At the top of my class are the member variables which include: private double newBalance; I then implement this....... or at least try........... my TestClass file has the following line of code: which calls the dispDetails method: Andy my output on the screen is: Current Account details for: **************************** Maureen Charlton : Account No: 3456 Balance: 0.0 What I wish to have is: Balance: 0.00 How do I manage to do this? When I input the amount i.e. deposit say, as �2.11 I actually get Balance 2.11
Steven Bell
Ranch Hand
Joined: Dec 29, 2004
Posts: 1071
posted Feb 26, 2005 12:47:00
0
The double isn't going to show the extra 0 because it doesn't need it. You will have to add it (after making the double a String ). You might want to look at the BigDecimal class. It might make your life a little easier.
Prashanth Lingala
Ranch Hand
Joined: Nov 13, 2004
Posts: 66
Try this, Now in your code, in main()... now...try this, This should work...
Have A Nice Day !!!
Maureen Charlton
Ranch Hand
Joined: Oct 04, 2004
Posts: 218
Steven Bell and Prashanth Lingala: Many thanks for your posts. Worked!
subject: Require output to 2 decimal places