package heima. Test09 ;
import java. util. Scanner ;
public class Money {
public static void main ( String [ ] args) {
Scanner sc = new Scanner ( System . in) ;
String result = "" ;
int money;
while ( true ) {
System . out. println ( "请输入一个金额" ) ;
money = sc. nextInt ( ) ;
if ( money > 0 && money <= 9999999 ) {
break ;
} else {
System . out. println ( "金额无效" ) ;
}
}
System . out. println ( money) ;
while ( true ) {
int arg = money % 10 ;
String money2 = getmoney ( arg) ;
result= money2 + result;
money = money / 10 ;
if ( money== 0 ) {
break ;
}
}
int count= 7 - result. length ( ) ;
for ( int i = 0 ; i < count; i++ ) {
result= "零" + result;
}
System . out. println ( result) ;
String [ ] arr= { "佰" , "拾" , "万" , "仟" , "佰" , "拾" , "元" } ;
for ( int i = 0 ; i < result. length ( ) ; i++ ) {
char ch = result. charAt ( i) ;
System . out. print ( ch) ;
System . out. print ( arr[ i] ) ;
}
}
public static String getmoney ( int args) {
String [ ] arr= { "零" , "壹" , "贰" , "叁" , "肆" , "伍" , "浏" , "柒" , "捌" , "玖" } ;
return arr[ args] ;
}
}