Code
#!/usr/bin/env python
from math import pi
testicles = [3.14, 4444.4444, 333.333, 69.69]
def mayne(numba):
if isinstance(numba, list) or isinstance(numba, tuple):
for e in numba:
ayy = str(e)[str(e).find('.')+1:str(e).find('.')+4]
yield ayy
elif isinstance(numba, float) or isinstance(numba, int):
ayy = str(numba)[str(numba).find('.')+1:str(numba).find('.')+4]
yield ayy
else:
print('ayy lmao wtf cus')
gin = mayne(testicles)
juice = [int(i) for i in gin]
apple = list(mayne(pi))
satin = list(mayne(666.777))
print(testicles)
print(juice)
print(pi)
print(apple)
print(666.777)
print(satin)
Output:
Code
C:\>python -i heh.py
[3.14, 4444.4444, 333.333, 69.69]
[14, 444, 333, 69]
3.141592653589793
['141']
666.777
['777']
>>>
A lot of languages have a libraries already compiled, not only are they better written, but they that can handle what you want. If you want to have fun though you'll try your own way too, at least for the experience. My code is terrible, inconsistent output, different types used, lists, strings, and crap showing but it functions for what is required and can be tweaked with some more time, using a functional style rather than conditional nonsense, and formatting the output better.
Code
>>> from math import pi
>>> print("{:.2f}".format(pi))
3.14
Don't know anything about Java and quite frankly I don't want to think about it because I just ate breakfast, but the proof of concept suggested (string -> find delimiter -> int) will work in any language.