import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
public class Test{
public String rtn1(long d, int b) {
String c = "##,####";
if (b != 0) {
c = c += ",";
}
for (int i = 0; i < b; i++) {
c += "#";
}
DecimalFormat df = new DecimalFormat(c);
String dfVal = df.format(d);
return dfVal;
}
public void rtn2(String r) {
String[] arr = r.split(",");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < arr.length; i++) {
sb.append(cal(arr[i]));
if (arr.length - i == 4) {
sb.append("조");
} else if (arr.length - i == 3) {
sb.append("억");
} else if (arr.length - i == 2) {
sb.append("만");
} else if (arr.length - i == 1) {
sb.append("원");
}
}
System.out.println("자바 환산된 단위 :: "+sb.toString());
}
public String cal(String s) {
char[] c = s.toCharArray();
int l = c.length;
String r = "";
for (int i = 0; i < c.length; i++) {
if (l - i == 4) {
switch(c[i])
{
case '1' :
r += "일천"; break;
case '2' :
r += "이천"; break;
case '3' :
r += "삼천"; break;
case '4' :
r += "사천"; break;
case '5' :
r += "오천"; break;
case '6' :
r += "육천"; break;
case '7' :
r += "칠천"; break;
case '8' :
r += "팔천"; break;
case '9' :
r += "구천"; break;
case '0' :
r += ""; break;
}
} else if (l - i == 3) {
switch(c[i])
{
case '1' :
r += "일백"; break;
case '2' :
r += "이백"; break;
case '3' :
r += "삼백"; break;
case '4' :
r += "사백"; break;
case '5' :
r += "오백"; break;
case '6' :
r += "육백"; break;
case '7' :
r += "칠백"; break;
case '8' :
r += "팔백"; break;
case '9' :
r += "구백"; break;
case '0' :
r += ""; break;
}
} else if (l - i == 2) {
switch(c[i])
{
case '1' :
r += "일십"; break;
case '2' :
r += "이십"; break;
case '3' :
r += "삼십"; break;
case '4' :
r += "사십"; break;
case '5' :
r += "오십"; break;
case '6' :
r += "육십"; break;
case '7' :
r += "칠십"; break;
case '8' :
r += "팔십"; break;
case '9' :
r += "구십"; break;
case '0' :
r += ""; break;
}
} else if (l - i == 1) {
switch(c[i])
{
case '1' :
r += "일"; break;
case '2' :
r += "이"; break;
case '3' :
r += "삼"; break;
case '4' :
r += "사"; break;
case '5' :
r += "오"; break;
case '6' :
r += "육"; break;
case '7' :
r += "칠"; break;
case '8' :
r += "팔"; break;
case '9' :
r += "구"; break;
case '0' :
r += ""; break;
}
}
}
return r;
}
public static void main(String[] args) throws Exception {
Test t = new Test();
long i = Long.parseLong("1034567890123456");
String rtn1 = t.rtn1(i, 0);
t.rtn2(rtn1);
}
}