编程:
关于人民币的转换:将一个阿拉伯数字转换成用中文汉字表示,如123转换成壹百贰十三
(注意:金额可能会达到百万,甚至亿)
关于人民币的转换:将一个阿拉伯数字转换成用中文汉字表示,如123转换成壹百贰十三
(注意:金额可能会达到百万,甚至亿)
解决方案 »
- JButton上的文本占据整个按钮
- java socket编程练习的问题
- 二维数组可不可以单独指定列的长度?
- ▆▆▆▆▆▆ Java代码注释的问题 ▆▆▆▆▆▆
- java io 读取utf-8的文件,出现了很怪异的事情
- 请问哪里有org.apache.lucene.analysis.cn.ChineseAnalyzer?
- 为什么drawString()输出的字符串不换行??打印机输出也是这个问题
- 大家帮忙看看这个聊天室能用吗,?谢谢了
- 运行了RESIN里面的HTTPD后 开HTTP://127.0.0.1:8080出现以下错误是怎么回事??
- 布尔函数
- eclipse生成还ibernate映射文件有问题,发送错误,"Generating Artifacts".
- 关于FTP服务器的问题!!
CREATE or replace Function Disp_dxje(THe_fyhj In Number) return varchar2 Is
/**********************************************************************
* 名称:大写金额转换函数 *
* 功能:收费打发票使用此函数 *
************************************************************************/
temp varchar2(16):=null; --the_fyhj字符串
temp1 varchar2(2):=null; --the_fyhj各小写字符
temp2 varchar2(2):=null; --the_fyhj各大写字符
temp3 varchar2(6):=null; --the_fyhj各大写单位
temp4 varchar2(60):=Null; --the_fyhj大写金额串
i number(2):=1;
j number(2);
pp number(2); --整数位长度
len number(2); --实际位长度
ll Number:=round(THe_fyhj,2);
Begin
if The_fyhj <0 Then
ll:=The_fyhj*(-1);
End if;
temp:=ltrim(rtrim(to_char(ll)),'0');--转成字符串,并去左边多余的零
pp:=Instr(temp,'.');
if pp>0 then
temp:=ltrim(Temp,'0'); --有小数时去掉右边多余的零
end if;
len:=length(temp);
if len>16 then --费用超限
return '费用超限';
End if;
if pp>0 then --整数位长度
pp:=pp-1;
Else
pp:=len;
End if;
for i in 1..len loop
temp1:=substr(temp,i,1); --取大写数值
if temp1='1' then
temp2:='壹';
elsif temp1='2' then
temp2:='贰';
elsif temp1='3' then
temp2:='叁';
elsif temp1='4' then
temp2:='肆';
elsif temp1='5' then
temp2:='伍';
elsif temp1='6' then
temp2:='陆';
elsif temp1='7' then
temp2:='柒';
elsif temp1='8' then
temp2:='捌';
elsif temp1='9' then
temp2:='玖';
elsif temp1='0' then
temp2:='零';
else
temp2:=null;
end if;
j:=pp+1-i;
If j=13 then --取大写单位
temp3:='万'; --亿级
elsif j=12 then
temp3:='仟'; --亿级
elsif j=11 then
temp3:='佰'; --亿级
elsif j=10 then
temp3:='拾'; --亿级
elsif j=9 then
temp3:='亿';
elsif j=8 then
temp3:='仟'; --万级
elsif j=7 then
temp3:='佰'; --万级
elsif j=6 then
temp3:='拾'; --万级
elsif j=5 then
temp3:='万';
elsif j=4 then
temp3:='仟';
elsif j=3 then
temp3:='佰';
elsif j=2 then
temp3:='拾';
elsif j=1 then
temp3:='元';
elsif j=-1 then
temp3:='角';
elsif j=-2 then
temp3:='分';
else
temp3:=null;
End if;
If j<-2 Then
temp2:=null;
End If;
If temp2='零' and temp3 Not In('亿','万','元') then --取消无效的单位
temp3:=null;
End if;
temp4:=temp4||temp2||temp3;
temp4:=replace(Temp4,'零零','零'); --取消无效的零
end loop;
--取消无效的零
temp4:=replace(Temp4,'零万','万');
temp4:=replace(Temp4,'零亿','亿');
temp4:=replace(Temp4,'亿万','亿');
If ll!=0 then
temp4:=replace(temp4,'零元','元');
End if;
if the_fyhj>=0 then
if (ll*10-floor(ll*10))=0 then --整数费用
temp4:='币'||temp4||'整';
else --小数费用
temp4:='币'||temp4;
end if;
Else
if (ll*10-floor(ll*10))=0 then
temp4:='币负'||temp4||'整';
else
temp4:='币负'||temp4;
end if;
End if;
return temp4;
Exception
When Others Then
return sqlerrm;
End Disp_dxje;declare
dxje varchar2(100);
begin
dxje:=disp_dxje(-132423423503.333);
dbms_output.put_line(dxje);
end;不要说你不会用JAVA调用...........
float money = new Float(121.01);
new ChangeMoney2().change(money);
int i =0;
System.out.println(i=i++);
} public void change(float money) {
if (0 >= money) {
System.out.println("一分钱都没有!");
} else {
String moneyStr = Float.toString(money);
StringBuffer buff = new StringBuffer();
String moneyInt = moneyStr.substring(0, moneyStr.indexOf("."));// 整数部分
String moneyPoit = moneyStr.substring(moneyStr.indexOf(".") + 1);// 小数部分
System.out.println(moneyStr); int length = moneyInt.length();// 整数的位数
int position = 0;// 整数部分标记位 while (position < length) { switch (length - position - 1) {
case 0: {
System.out.println("整数部分:" + moneyInt + " 小数部分:"
+ moneyPoit);
position = add(buff, moneyInt, position);
buff.append("圆");
continue;
} case 9:
case 5:
case 1: {
position = add(buff, moneyInt, position);
buff.append("拾");
continue;
} case 10:
case 6:
case 2: {
position = add(buff, moneyInt, position);
buff.append("百");
continue;
} case 7:
case 3: {
position = add(buff, moneyInt, position);
buff.append("千");
continue;
} case 4: {
position = add(buff, moneyInt, position);
buff.append("万");
continue;
} case 8: {
position = add(buff, moneyInt, position);
buff.append("亿");
continue;
} }
}
if (!moneyPoit.equals("0")) {
System.out.println("只精确到小数点1位!");
add(buff, moneyPoit, 0);
buff.append("角");
}
moneyStr = buff.toString();
moneyStr = moneyStr.replaceAll("0", "零");
moneyStr = moneyStr.replaceAll("1", "壹");
moneyStr = moneyStr.replaceAll("2", "贰");
moneyStr = moneyStr.replaceAll("3", "叁");
moneyStr = moneyStr.replaceAll("4", "肆");
moneyStr = moneyStr.replaceAll("5", "伍");
moneyStr = moneyStr.replaceAll("6", "陆");
moneyStr = moneyStr.replaceAll("7", "柒");
moneyStr = moneyStr.replaceAll("8", "捌");
moneyStr = moneyStr.replaceAll("9", "玖");
System.out.println(moneyStr);
}
} public int add(StringBuffer buff, String str, int i) { buff.append(str.charAt(i));
return ++i;
}}
但是也有一个问题,你并没有指定金额的上限,也许判断远远都不能满足