请大虾帮忙
我在编一个小程序,是关于小写金额转换成大写的问题。
我的思路是1、输入2、转换为整数3、转换为字符串4、得到字符串的长度5、将字符一个一个取出,判断它是几,与开始的数组对照,取出相应的值。将取出的值放入字符串,最后输出。
可是我的程序就是运行不出来,请帮我看一下。谢谢
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class ZhuanHuan {
private static String[] shuzi = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒",
"捌", "玖" };
private static String[] danwei = { "分", "角", "元", "拾", "佰", "仟", "万", "拾",
"佰", "仟", "亿" };
public static void main(String[] args) {
double payment = 0;
String stemp="";
String money[];
money=new String[100];
int itemp;
System.out.println("请您输入要转换的钱数:");
InputStreamReader ir;
BufferedReader in;
ir = new InputStreamReader(System.in);
in = new BufferedReader(ir);
try {
String s = in.readLine();
payment = Double.parseDouble(s);//读入金额
} catch (Exception e) {
System.out.println(e.getMessage());
}
if (payment<0.01)
{System.out.println("您输入的金额过小,请您输入正确的金额");}
else {
if (payment<0)
{System.out.println("不能输入负数金额,请您输入正确金额");}
else {
if (payment>999999999)
{System.out.println("您输入的金额过大,请您输入正
确额");}
else{{
{
int ipayment = (int) Math.floor(payment * 100 + 0.5); //转换成分并四舍五入
String spayment = String.valueOf(ipayment);//转化为字符串
int length=spayment.length();//取得转化后的字符串的长度
int danweinum=0;
int i=0;
while (length>= 0){
int num=length-1; stemp = spayment.substring(num, 1);//stemp加入spayment的第num个字符
itemp = Integer.parseInt(stemp);//把读入的数字转化为整型
money[i]=danwei[danweinum];
i=i+1;
money[i]=shuzi[itemp];
danweinum++;
i++;
length--;
}
}
System.out.println("转化后的结果是:");
for(int j=money.length-1;j>=0;j--){
System.out.print(money[j]);
}
}}
}
}
}
}