public class Main {
public static void main
(String args
[]) { System.
out.
println(abreviarComK
(1000)); System.
out.
println(abreviarComK
(2000)); System.
out.
println(abreviarComK
(10000)); System.
out.
println(abreviarComK
(300));
}
public static String abreviarComK
(long numero
) {
if (numero < 1000) {
return Long.
toString(numero
); } else {
return (numero/1000.0 + "k").replace(".", ",");
}
}
}
cHVibGljIGNsYXNzIE1haW4gewoKICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmcgYXJnc1tdKSB7CiAgICBTeXN0ZW0ub3V0LnByaW50bG4oYWJyZXZpYXJDb21LKDEwMDApKTsKICAgIFN5c3RlbS5vdXQucHJpbnRsbihhYnJldmlhckNvbUsoMjAwMCkpOwogICAgU3lzdGVtLm91dC5wcmludGxuKGFicmV2aWFyQ29tSygxMDAwMCkpOwogICAgU3lzdGVtLm91dC5wcmludGxuKGFicmV2aWFyQ29tSygzMDApKTsKCiAgfQoKCiAgcHVibGljIHN0YXRpYyBTdHJpbmcgYWJyZXZpYXJDb21LKGxvbmcgbnVtZXJvKSB7CgogICAgaWYgKG51bWVybyA8IDEwMDApIHsKICAgICAgcmV0dXJuIExvbmcudG9TdHJpbmcobnVtZXJvKTsKICAgIH0gZWxzZSB7CiAgICAgIHJldHVybiAobnVtZXJvLzEwMDAuMCArICJrIikucmVwbGFjZSgiLiIsICIsIik7CiAgICB9CgogIH0KCn0=