Smile9870

1005. Spell It Right (20)

import java.util.Scanner;

public class Main {

    public static void main(String[] args)  {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        char[] ch=s.toCharArray();
        int sum=0;
        for(int i=0;i<ch.length;i++) {
            sum+=(ch[i]-48);
        }
        s=Integer.toString(sum);
        char[] c=s.toCharArray();
        if(c[0]=='0') {
            System.out.print("zero");
        }
        if(c[0]=='1') {
            System.out.print("one");
        }
        if(c[0]=='2') {
            System.out.print("two");
        }
        if(c[0]=='3') {
            System.out.print("three");
        }
        if(c[0]=='4') {
            System.out.print("four");
        }
        if(c[0]=='5') {
            System.out.print("five");
        }
        if(c[0]=='6') {
            System.out.print("six");
        }
        if(c[0]=='7') {
            System.out.print("seven");
        }
        if(c[0]=='8') {
            System.out.print("eight");
        }
        if(c[0]=='9') {
            System.out.print("nine");
        }
        for(int i=1;i<c.length;i++) {
            if(c[i]=='0') {
                System.out.print(" zero");
            }
            if(c[i]=='1') {
                System.out.print(" one");
            }
            if(c[i]=='2') {
                System.out.print(" two");
            }
            if(c[i]=='3') {
                System.out.print(" three");
            }
            if(c[i]=='4') {
                System.out.print(" four");
            }
            if(c[i]=='5') {
                System.out.print(" five");
            }
            if(c[i]=='6') {
                System.out.print(" six");
            }
            if(c[i]=='7') {
                System.out.print(" seven");
            }
            if(c[i]=='8') {
                System.out.print(" eight");
            }
            if(c[i]=='9') {
                System.out.print(" nine");
            }
        }
    }

}

 

posted on 2018-01-03 16:57  Smile9870  阅读(113)  评论(0编辑  收藏  举报

导航