-pat-java-5-23 Currency conversion (20 points)

Source: Internet
Author: User

Enter an integer (no more than 9 digits) to represent a renminbi value (in yuan), please convert the uppercase Chinese format to the financial requirements. such as 23108 Yuan, converted into a "Wan Baize ba" Yuan. In order to simplify the output, the lowercase English letter a-j order represents the capital number 0-9, with S, B, Q, W, y respectively represents pick, hundred, thousand, million, billion. So 23108 yuan should be converted to output as "Cwdqbbai" Yuan.

Input format:

The input gives a non-negative integer that does not exceed 9 bits in a row.

Output format:

Outputs the converted results in a row. Note that the usage of "0" must conform to the Chinese habit.

Input Sample 1:
813227345
Output Example 1:
iYbQdBcScWhQdBeSf
Input Sample 2:
6900
Output Example 2:
gQjB


It's a very troublesome question.
Note Test data 0-A1-B200-CB 101001000-BYABBWBQ 100101000-BYABSWBQ 100011000-BYABWBQ
Import Java.util.scanner;public class main{public static void Main (string[] args) {Scanner sc = new Scanner (system.in); STRING[]DW = new STRING[10];d w[1] = ";d w[2] =" S ";d w[3] =" B ";d w[4] =" Q ";d w[5] =" W ";d w[6] =" S ";d w[7] =" B ";d w[8] =" Q " ;d w[9] = "Y"; String[]num = new String[10];num[0] = "a"; num[1] = "B"; num[2] = "C"; num[3] = "D"; num[4] = "E"; num[5] = "F"; num[6] = "g"; nu M[7] = "h"; num[8] = "I"; num[9] = "J"; String s = sc.next (); int len = S.length (); if (len==1) {//Enter a single number considered separately System.out.println (Num[s.charat (0)-48]);} else{for (int i=0; i<len; i++) {if (S.charat (i) -48!=0) {//digit not 0 in case System.out.print (Num[s.charat (i) -48]+dw[len-i]) ;}   else if (i<len-1&&i!=len-5&& (S.charat (i) -48==0&&s.charat (i+1) -48!=0) {//digit is 0 There are multiple successive 0 value outputs of a System.out.print (Num[s.charat (i)-48]);} else if (Len>5&&i==len-5&&s.charat (i) -48==0) {//Wanwei is 0 if (Len==9&&s.charat (1) -48==0 &&s.charat (2) -48==0&&s.charat (3) -48==0) {//100 million Case}else{system.out.print ("W");}}}}} 


-pat-java-5-23 Currency conversion (20 points)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.