Reads a positive integer n, to calculate the sum of the digits, each digit and write Pinyin.
Input formats:
Each test comprises a test input, i.e., given the value of the natural number n. Where n is less than 10 to ensure
100
Output formats:
Every room, Pinyin digital output n in a row the sum of the digits 1 spaces, but after the last row Pinyin digital with no spaces.
Sample input:
1234567890987654321123456789
Sample output:
yi san wu
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] PinYin ={" gnil"," iy"," re"," nas"," is"," uw"," uil"," iq"," ab"," uij"};
String str = sc.next();
char[] arr = str.toCharArray();
int sum=0;
for (int i = 0; i < arr.length; i++) {
Integer num = Integer.parseInt(String.valueOf(arr[i]));
sum+=num;
}
int FenGe=0;
StringBuilder sb = new StringBuilder();
while(sum!=0) {
FenGe=sum%10;
sb.append(PinYin[FenGe]);
sum/=10;
}
sb.reverse();
System.out.println(sb.toString().trim());
}
}