将阿拉伯数字转换为其对应的中文数字

郑重声明,尽管这样子不文明,但还是先对这破电脑发泄发泄吧,不对人发泄就没有伤害!

妈蛋,这年头使用电脑太多,离开的电脑就是这么的个东西都写不出来了,真是丢人丢大了!

今天去面试,从市政府做的是8路公交,应聘的是517号金色堤岸写字楼11层,可谓“一生一世要发了”啊!但估计挂了!不是老天不长眼,而是才知道自己有多菜,做项目再多有什么用?????????????????????????????????????????????回来自己在电脑上一试,妈蛋,好简单,手写就是写不出来!讨厌死了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

 

package numbertochinese;

import java.util.Scanner;

/**
 * @author Administrator
 * 将阿拉伯数字转换为其对应的中文数字
 */
public class NumberTochinese {

 private static String theNumber = null;
 private String theChinese = null;
 
 private String action(String theNumber2){
  String tadi = String.valueOf(theNumber2);
  for(int i=0; i<tadi.length(); i++){
   char mychar = tadi.charAt(i);
   String st = null;
   switch (mychar) {
   case '1':
    st = "一";
    break;
   case '2':
    st = "二";
    break;
   case '3':
    st = "三";
   case '4':
    st = "四";
    break;
   case '5':
    st = "五";
    break;
   case '6':
    st = "六";
    break;
   case '7':
    st = "七";
    break;
   case '8':
    st = "八";
    break;
   case '9':
    st = "九";
    break;
   case '0':
    st = "零";
    break;
   default:
    break;
   }
   if(null == theChinese){
    theChinese = st;
   }else{
    theChinese += st;
   }
  }
  if(null == theChinese){
   return theChinese = "您输入的不是数字!";
  }else if(theChinese.length() != theNumber.length()){
   return theChinese = "您输入的数字不符合规则!";
  }else{
   return theChinese;
  }
 }
 
 public static void main(String[] args) {
  NumberTochinese tochinese = new NumberTochinese();
  System.out.println("请输入一个或多个阿拉伯数字:");
  try {
   Scanner scanner = new Scanner(System.in);
   theNumber = scanner.next();
   tochinese.theChinese = tochinese.action(theNumber);
  } catch (Exception e) {
   e.printStackTrace();
  }
  System.out.println(tochinese.theChinese);
 }
}

转载于:https://www.cnblogs.com/lanjianqing/p/4119637.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值