展开全部
public String GetBigMoney(double eSender)
{
double NewMoney;
int Index, len, flag;
String StrTemp = null;
char[] p;
String Number[]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
String MonetaryUnit[] = {"万","仟","佰","拾","亿","仟","佰","拾","万","仟","佰","拾","元","角","分"} ;
NewMoney = Math.abs(eSender);
System.out.println(NewMoney);
DecimalFormat deciformat;
deciformat=(DecimalFormat)DecimalFormat.getInstance();
deciformat.applyPattern("#######");
String m = java.lang.String.valueOf(deciformat.format(NewMoney * 100));
int i;
if((i = m.indexOf('.')) != -1)
m = m.substring(0, i);
p = new char[m.length()];
//p = new char[40];
m.getChars(0, m.length(), p, 0);
//len=m.length();
if (NewMoney > 100000000000.00) {
StrTemp = ""; // FloatAsComma( NewMoney, False );
return StrTemp;
}
if (NewMoney < 0.01) {
StrTemp = "零";
return StrTemp;
}
if (eSender<0) {
StrTemp = "负";
}
else {
StrTemp = "";
}
flag = 1;
len =p.length;
System.out.println("1111");
System.out.println(len);
for (Index=(15-len);Index<15;Index++)
{
if (p[Index - 15 + len]!='0')
{
StrTemp = StrTemp + Number[Integer.parseInt(String.valueOf(p[Index-15+len]))];
StrTemp = StrTemp + MonetaryUnit[Index];
}
else
{
if (Index == 5)
{
if ((p[Index - 14 + len]!= '0') || (p[Index-13+len] != '0'))
{
StrTemp = StrTemp + MonetaryUnit[Index + 3];
flag = 0;
}
}
else
{
if ((Index == 12) ||( (Index == 8) && (flag ==1)) || (Index == 4))
{
StrTemp = StrTemp + MonetaryUnit[Index];
}
if ((p[Index-15 + len] != '0') && (Index != 14))
{
StrTemp = StrTemp +Number[Integer.parseInt(String.valueOf(p[Index-15+len]))];
;
}
}
}
}
if (p[m.length()-1] == '0')
{
StrTemp = StrTemp + "整";
}
return StrTemp;
}
{
double NewMoney;
int Index, len, flag;
String StrTemp = null;
char[] p;
String Number[]={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
String MonetaryUnit[] = {"万","仟","佰","拾","亿","仟","佰","拾","万","仟","佰","拾","元","角","分"} ;
NewMoney = Math.abs(eSender);
System.out.println(NewMoney);
DecimalFormat deciformat;
deciformat=(DecimalFormat)DecimalFormat.getInstance();
deciformat.applyPattern("#######");
String m = java.lang.String.valueOf(deciformat.format(NewMoney * 100));
int i;
if((i = m.indexOf('.')) != -1)
m = m.substring(0, i);
p = new char[m.length()];
//p = new char[40];
m.getChars(0, m.length(), p, 0);
//len=m.length();
if (NewMoney > 100000000000.00) {
StrTemp = ""; // FloatAsComma( NewMoney, False );
return StrTemp;
}
if (NewMoney < 0.01) {
StrTemp = "零";
return StrTemp;
}
if (eSender<0) {
StrTemp = "负";
}
else {
StrTemp = "";
}
flag = 1;
len =p.length;
System.out.println("1111");
System.out.println(len);
for (Index=(15-len);Index<15;Index++)
{
if (p[Index - 15 + len]!='0')
{
StrTemp = StrTemp + Number[Integer.parseInt(String.valueOf(p[Index-15+len]))];
StrTemp = StrTemp + MonetaryUnit[Index];
}
else
{
if (Index == 5)
{
if ((p[Index - 14 + len]!= '0') || (p[Index-13+len] != '0'))
{
StrTemp = StrTemp + MonetaryUnit[Index + 3];
flag = 0;
}
}
else
{
if ((Index == 12) ||( (Index == 8) && (flag ==1)) || (Index == 4))
{
StrTemp = StrTemp + MonetaryUnit[Index];
}
if ((p[Index-15 + len] != '0') && (Index != 14))
{
StrTemp = StrTemp +Number[Integer.parseInt(String.valueOf(p[Index-15+len]))];
;
}
}
}
}
if (p[m.length()-1] == '0')
{
StrTemp = StrTemp + "整";
}
return StrTemp;
}
展开全部
//给你的简单的万位整数转换,接下来思考一下吧
package com.ldc.test;
import java.util.Scanner;
/**
*
* @author 愿做无聊听众6
*
*/
public class Test {
public static void main(String[] args) {
String[] str = "零,壹,贰,叁,肆,伍,陆,柒,捌,玖,拾,佰,仟,万,亿,圆".split("\\,");
String[] str2 = "拾,佰,仟,万,亿".split("\\,");
Scanner scan = new Scanner(System.in);
int input = scan.nextInt();
String money=String.valueOf(input);
StringBuffer sbf = new StringBuffer();
for (int i = money.length(); i >0 ; i--) {
if(sbf.length()==0){
sbf.insert(0,"圆整");
}else{
sbf.insert(0,str2[money.length()-i-1]);
}
sbf.insert(0,str[Integer.parseInt(String.valueOf(money.charAt(i-1)))]);
}
System.out.print(sbf);
}
}
package com.ldc.test;
import java.util.Scanner;
/**
*
* @author 愿做无聊听众6
*
*/
public class Test {
public static void main(String[] args) {
String[] str = "零,壹,贰,叁,肆,伍,陆,柒,捌,玖,拾,佰,仟,万,亿,圆".split("\\,");
String[] str2 = "拾,佰,仟,万,亿".split("\\,");
Scanner scan = new Scanner(System.in);
int input = scan.nextInt();
String money=String.valueOf(input);
StringBuffer sbf = new StringBuffer();
for (int i = money.length(); i >0 ; i--) {
if(sbf.length()==0){
sbf.insert(0,"圆整");
}else{
sbf.insert(0,str2[money.length()-i-1]);
}
sbf.insert(0,str[Integer.parseInt(String.valueOf(money.charAt(i-1)))]);
}
System.out.print(sbf);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我觉得那小写钱数转换成String 然后再一个数字一个数字的取 并算数小数点前的数字个数
之后写个方法分别把0-9的数字转换成汉字
利用小数点前的个数决定分别汉字后插入 百 十 个
之后写个方法分别把0-9的数字转换成汉字
利用小数点前的个数决定分别汉字后插入 百 十 个
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public class Rmb {
public static String ZhuanHuan(int x)
{
String y="请输入3位数";
if(x==0)
{
y="零";
}
if(x==1)
{
y="壹";
}
if(x==2)
{
y="贰";
}
if(x==3)
{
y="叁";
}
if(x==4)
{
y="肆";
}
if(x==5)
{
y="伍";
}
if(x==6)
{
y="陆";
}
if(x==7)
{
y="柒";
}
if(x==8)
{
y="捌";
}
if(x==9)
{
y="玖";
}
return y;
}
public static void main(String[] args) {
Integer a=Integer.valueOf(args[0]);
int b=a.intValue();
System.out.println(b+"元");
int c=(int)(b/100);
int d=(int)((b-100*c)/10);
int e=(int)(b-(100*c+10*d));
String c1,d1,e1;
c1=ZhuanHuan(c);
d1=ZhuanHuan(d);
e1=ZhuanHuan(e);
System.out.println(c1+"百"+d1+"十"+e1+"元");
}
}
测试:
java Rmb 123得结果:
123元
壹百贰十叁元
可以根据这个代码改一改嘛
public static String ZhuanHuan(int x)
{
String y="请输入3位数";
if(x==0)
{
y="零";
}
if(x==1)
{
y="壹";
}
if(x==2)
{
y="贰";
}
if(x==3)
{
y="叁";
}
if(x==4)
{
y="肆";
}
if(x==5)
{
y="伍";
}
if(x==6)
{
y="陆";
}
if(x==7)
{
y="柒";
}
if(x==8)
{
y="捌";
}
if(x==9)
{
y="玖";
}
return y;
}
public static void main(String[] args) {
Integer a=Integer.valueOf(args[0]);
int b=a.intValue();
System.out.println(b+"元");
int c=(int)(b/100);
int d=(int)((b-100*c)/10);
int e=(int)(b-(100*c+10*d));
String c1,d1,e1;
c1=ZhuanHuan(c);
d1=ZhuanHuan(d);
e1=ZhuanHuan(e);
System.out.println(c1+"百"+d1+"十"+e1+"元");
}
}
测试:
java Rmb 123得结果:
123元
壹百贰十叁元
可以根据这个代码改一改嘛
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
自己写个算法贝。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询