I am relatively new to Java and J2EE, and have programmed a banking web application at work.

However, there is an algorithm I need to program and it involves breaking a number down to do calculations on the individual numbers that make it up.

The number will be about 14 digits long max, but I was wondering what the best way to break the number down in java is (ie the number 123456789 will need to have the last two digits added to the fifth digit etc).

Any advice will be appreciated.

Rob.

Originally posted by Rob Lord:

Hello

I am relatively new to Java and J2EE, and have programmed a banking web application at work.

However, there is an algorithm I need to program and it involves breaking a number down to do calculations on the individual numbers that make it up.

The number will be about 14 digits long max, but I was wondering what the best way to break the number down in java is (ie the number 123456789 will need to have the last two digits added to the fifth digit etc).

Any advice will be appreciated.

Rob.

Dear Rob,

What are you looking for I can illustrate you for an example:

if you have any digit e.g 1245364

then you need every digit seperately like

4

6

3

5

4

2

1

This is an example. If you would like to this one only... Then it quite easy.

I can show you a code snippet

This would create following output according to the input

**"123234"**

a[0]=4

a[1]=3

a[2]=2

a[3]=3

a[4]=2

a[5]=1

Hope your problem has been covered in this logic...

If still any concern then revert with concerns.

The Best way to predict your future is to create it - Every great individual common man

I know it probably seems simple to most, but I couldn't figure out a simple way to do it, and couldn't seem to find an example anywhere.

I will print this post off for future reference and your answer is much appreciated Ankur.

Rob.

Originally posted by Srinivas Kalvala:

Hello,

The % and / operator will help a lot. If you have worked with C or C++, then you might have seen lot of tricky programs with these two operators.

Did You just bumped the thread???..

Anyways thankx for this usefull Important Information

The Best way to predict your future is to create it - Every great individual common man