日期:2008-05-14  浏览次数:20505 次

using System;

namespace ChangeMoney
{
/// <summary>

/// ChangeManage 的摘要说明。
/// </summary>
public class ChangeMoneyClass
{
public static string MoneytoEng(string n)
{
// string result="";
string m=getFloat(n);
string strfloat=" point"+m.Replace("0"," zero").Replace("1"," one").Replace("2"," two").Replace("3"," three").Replace("4"," four").Replace("5"," five").Replace("6"," six").Replace("7"," seven").Replace("8"," eight").Replace("9"," nine");
string []b=new string[6];
int i=0;
double t=double.Parse(n);
if (getInteger(n)=="0")
{
b[0]="zero";
}


// for (i=0;t>=1000.0;i++)
else
{
do
{

int k=int.Parse(getInteger(t.ToString()))%1000;
b[i]=getNum3(k);
t=t/1000.0;
if (int.Parse(getInteger(t.ToString()))<1000 & int.Parse(getInteger(t.ToString()))>0)
{
switch(i)
{
case 0:
if(k!=0)
{
b[i]=getNum3(int.Parse(getInteger(t.ToString())))+" thousand and "+b[i];
}
else
{
b[i]=getNum3(int.Parse(getInteger(t.ToString())))+" thousand "+b[i];
}
break;
case 1:
if(k!=0)
{
b[i]=getNum3(int.Parse(getInteger(t.ToString())))+" million and "+b[i];
}
else
{
b[i]=getNum3(int.Parse(getInteger(t.ToString())))+" million "+b[i];
}
break;
case 2:
if(k!=0)
{
b[i]=getNum3(int.Parse(getInteger(t.ToString())))+" billion and "+b[i];
}
else
{
b[i]=getNum3(int.Parse(getInteger(t.ToString())))+" billion "+b[i];
}
break;
case 3:
if(k!=0)
{
b[i]=getNum3(int.Parse(getInteger(t.ToString())))+" trillion and "+b[i];
}
else
{
b[i]=getNum3(int.Parse(getInteger(t.ToString())))+" trillion "+b[i];
}
break;
default:
b[i]=" the number is too large!!!";
break;
}
}
else if(int.Parse(getInteger(t.ToString()))>=1000)
{
switch(i)
{
case 0:
b[i]=" thousand "+b[i];
break;
case 1:
b[i]=" million "+b[i];
break;
case 2:
b[i]=" billion "+b[i];
break;
case 3:
b[i]=" trillion "+b[i];
break;
default:
b[i]=" the number is too large!!!";
break;
}
}
// while(i>=0)
// {
// result=result+b[i];
// i--;
// }
i++;
}while(t>=1000.0);
}
// return result;
return b[5]+b[4]+b[3]+b[2]+b[1]+b[0]+strfloat;

//0-999

}
private static string getNum3(int n)
{
string m=n.ToString();
string []b=new string[3];
string str="";
if(n>=100 & n<1000)
{