6. แยกย่อย

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 6-8  เมท็อดแปลงเลขโดดเป็นคำไทย
  // เมท็อดแปลงเลขโดดเป็นคำไทย, digit มีค่าตั้งแต่ 0,1,2,...,9
  public static String digit2text(int digit) {
    String t = "";
    if (digit == 0) t = "ศูนย์";
    else if (digit == 1) t = "หนึ่ง";
    else if (digit == 2) t = "สอง";
    else if (digit == 3) t = "สาม";
    else if (digit == 4) t = "สี่";
    else if (digit == 5) t = "ห้า";
    else if (digit == 6) t = "หก";
    else if (digit == 7) t = "เจ็ด";
    else if (digit == 8) t = "แปด";
    else if (digit == 9) t = "เก้า";
    else t = "???";
    return t;
  }
©2009 S.Prasitjutrakul