public class Financial { public static void convertNum(float value) { int cents = (int)Math.round((value*100) - ((int)value*100)); if (value < 1) System.out.printf("Zero "); if (value >= 1000) { int thousands = ((int)value / 1000); int hundredthousands = ((int)thousands / 100); int xthousands = (int)(thousands % 100); int tenthousands = (((int)thousands % 100) / 10); int onethousands = ((int)thousands %10); int newvalue = ((int)value % 1000); value = (int)newvalue; Financial.switch1(hundredthousands); if (hundredthousands != 0) System.out.printf("Hundred "); if (xthousands > 19) { Financial.switch2(tenthousands); Financial.switch1(onethousands); } else Financial.switch1(xthousands); System.out.printf("Thousand "); } int hundreds = ((int)value / 100); int xtens = (int)(value % 100); int tens = (((int)value % 100 ) / 10) ; int ones = ((int)value % 10); Financial.switch1(hundreds); if (hundreds != 0) System.out.printf("Hundred "); if (xtens > 19) { Financial.switch2(tens); Financial.switch1(ones); } else Financial.switch1(xtens); System.out.printf("and " +cents +"/00 Dollars"); System.out.println(""); } private static void switch1 (int digit) { switch (digit) { case 1: System.out.printf ("One ");break; case 2: System.out.printf ("Two "); break; case 3: System.out.printf ("Three "); break; case 4: System.out.printf ("Four "); break; case 5: System.out.printf ("Five "); break; case 6: System.out.printf ("Six "); break; case 7: System.out.printf ("Seven "); break; case 8: System.out.printf ("Eight "); break; case 9: System.out.printf ("Nine "); break; case 10: System.out.printf ("Ten "); break; case 11: System.out.printf ("Eleven "); break; case 12: System.out.printf ("Twelve "); break; case 13: System.out.printf ("Thirteen "); break; case 14: System.out.printf ("Fourteen "); break; case 15: System.out.printf ("Fifteen "); break; case 16: System.out.printf ("Sixteen "); break; case 17: System.out.printf ("Seventeen "); break; case 18: System.out.printf ("Eighteen "); break; case 19: System.out.printf ("Nineteen "); break; } } private static void switch2 (int tens) { switch(tens) { case 2: System.out.printf ("Twenty "); break; case 3: System.out.printf ("Thirty "); break; case 4: System.out.printf ("Fourty "); break; case 5: System.out.printf ("Fifty "); break; case 6: System.out.printf ("Sixty "); break; case 7: System.out.printf ("Seventy "); break; case 8: System.out.printf ("Eighty "); break; case 9: System.out.printf ("Ninety "); break; } } }