posted 14 years ago
You could probably write a program to treat the * or # as a decimal point, but that would be a bit confusing. I'm thining the simplest solution would be to just omit the decimal and assume the user is entering cents. Say the user types 1-2-3-4-5, after each key the display would read:
$0.00
(1)
$0.01
(2)
$0.12
(3)
$1.23
(4)
$12.34
(5)
$123.45
Then perhaps OK would signal the end of input.
Would that solve your problem?
(I know little about J2ME, but it seems like someone should have already written code for this somewhere...)
$0.00
(1)
$0.01
(2)
$0.12
(3)
$1.23
(4)
$12.34
(5)
$123.45
Then perhaps OK would signal the end of input.
Would that solve your problem?
(I know little about J2ME, but it seems like someone should have already written code for this somewhere...)
"I'm not back." - Bill Harding, Twister
posted 14 years ago
Mark have you reviewed Sun's article at mobility site(formely wireless.java.sun) where the author goe sinto how to account for dollars and cents to do conversions from US to other currencies in j2me?
MobileBytes blog - Sharing Technology - My Programming Knols
posted 14 years ago
Yes, after some odd attempts on my part, I have used Jim's solution to allow entry of decimals. The field starts with ". " Then as you type in numbers it appends it to the right side, and moves all the numbers one to the left, keeping the decimal point in the third position.
At first I tried char[] to add the new number to the beginning then just swap the third and fourth elements to move the decimal point back, but that ended up being too much code.
Here is my DecimalEntry class
Darn Copy and Paste, didn't keep my 4 spaces on my tabbing.
Or my carriage returns
Mark
[ December 23, 2003: Message edited by: Mark Spritzler ]
[ December 23, 2003: Message edited by: Mark Spritzler ]
At first I tried char[] to add the new number to the beginning then just swap the third and fourth elements to move the decimal point back, but that ended up being too much code.

Here is my DecimalEntry class
Darn Copy and Paste, didn't keep my 4 spaces on my tabbing.

Or my carriage returns
Mark
[ December 23, 2003: Message edited by: Mark Spritzler ]
[ December 23, 2003: Message edited by: Mark Spritzler ]

Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |