Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!

# Decimal point

Mark Spritzler
ranger
Sheriff
Posts: 17278
6
Is there anyway for a cell phone user to enter a decimal point. I guess if not, no one can create a Tip Calculator for a Cell Phone because the user wouldn't be able to enter in the cents of the bill.
Mark

Jim Yingst
Wanderer
Sheriff
Posts: 18671
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.
(I know little about J2ME, but it seems like someone should have already written code for this somewhere...)

Fred Grott
Ranch Hand
Posts: 346
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?

Mark Spritzler
ranger
Sheriff
Posts: 17278
6
No Fred I haven't. I will go try and find it. Jim, your solution might be feasible. I'll see if I can do that.
Thanks guys
Mark

Mark Spritzler
ranger
Sheriff
Posts: 17278
6
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 ]