怎么把输入的阿拉伯数字转成英文?

 我来答
无查画
2022-03-03
知道答主
回答量:17
采纳率:0%
帮助的人:5791
展开全部

到百度找到这个工具,然后录入你需要的数字,点击翻译就出来了。

璟主7902

2022-06-29 · 贡献了超过136个回答
知道答主
回答量:136
采纳率:0%
帮助的人:2万
展开全部
很简单的程序,我就不写注释了吧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];
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
霓裳or离殇TLFV

2022-06-29 · 超过11用户采纳过TA的回答
知道答主
回答量:1270
采纳率:0%
帮助的人:35.8万
展开全部
很简单的程序,我就不写注释了吧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];
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
既要还噬

2022-06-29 · 贡献了超过398个回答
知道答主
回答量:398
采纳率:0%
帮助的人:11.2万
展开全部
很简单的程序,我就不写注释了吧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];
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
q4...c@163.com

2022-06-29 · 贡献了超过545个回答
知道答主
回答量:545
采纳率:0%
帮助的人:16.2万
展开全部
很简单的程序,我就不写注释了吧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];
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(5)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式