仗剑拂衣去
103:one hundred and three.273:two hundred and seventy three491:four hundred and ninty one500:five hundred110:one hundred and ten、double one O(读呕)【这个是做110报警电话讲】4901:four thousand and nine hundred and one3214:three thousand and two hundred and fourteen2586:two thousand and five hundred and eighty six7694:seven thousand and six hundred and ninty four8537:eight thousand and five hundred and thirty seven12357:twelve thousand and three hundred and fifty seven23645:twenty-three thousand and six hundred and forty five41078:forty-one thousand and seventy eight89100:eighty-nine thousand and one hundred133000:one hundred and thirty-three thousand276000:two hundred and seventy-six thousand384000:three hundred and eighty-four thousand874000:eight hundred and seventy-four thousand470000:forty-seven hundred thousand560000:fifty-six hundred thousand2100000:twenty-one hundred thousand200000000:two hundred million356000000:three hundred and fifty-six million676000000:six hundred and seventy-six million英语是以3个0为一个单位 汉语是以4个0为一个单位英语就是 hundred thousand million billion这样如果这些数次前没有数字则要在这些数次后面+s 再与of组合用
小莹catherine
很简单的程序,我就不写注释了吧import java.util.Scanner;public class EnglishNumberFormatter { private static final String[] BITS = {"ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT,", "NINE", "TEN"}; private static final String[] TEENS = {"ELEVEN", "TWELF", "THIRTEEN", "FOURTEEN", "FIFTEEN", "SIXTEEN", "SEVETEEN", "EIGHTEEN", "NIGHTEEN"}; private static final String[] TIES = {"TWENTY", "THRITY", "FORTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY"}; private static Scanner sc; public static void main(String[] args) { sc = new Scanner(***.in); int num = 0; while(num != -1) { System.out.print("Please type a number between 0 and 999: "); num = sc.nextInt(); if(num <0 || num > 999) { continue; } String english = toEnglish(num); System.out.println(english); } System.out.println("Thank you for using this program"); } private static String toEnglish(int num) { if(num == 0) { return "Zero"; } StringBuffer buffer = new StringBuffer(); if(num >= 100) { buffer.append(pickHunder(num)); if(num % 100 != 0) { buffer.append(" AND "); } num -= (num / 100) * 100; } boolean largerThan20 = false; if(num >= 20) { largerThan20 = true; buffer.append(pickTies(num)); num -= (num / 10) * 10; } if(!largerThan20 && num > 10) { buffer.append(pickTeens(num)); num = 0; } if(num > 0) { String bit = pickBits(num); if(largerThan20) { buffer.append(" "); } buffer.append(bit); } return buffer.toString(); } private static String pickHunder(int num) { int hunder = num / 100; return BITS[hunder - 1] + " HUNDER"; } private static String pickTies(int num) { int ties = num / 10; return TIES[ties - 2]; } private static String pickTeens(int num) { return TEENS[num - 11]; } private static String pickBits(int num) { return BITS[num - 1]; }}