(C #) uppercase conversion of numeric currency

Source: Internet
Author: User
Capital | currency | Convert I now do the project requirements on the numeric currency, converted to uppercase, search on the internet for a long time, did not find C # written type, had to write their own, testing, but also to meet the requirements, but the algorithm is a bit cumbersome, there is no one to change the shrimp again
Here's My Code:
Using System;
Using System.Drawing;
Using System.Collections;
Using System.ComponentModel;
Using System.Windows.Forms;
Using System.Data;

Namespace Winmarket
{
<summary>
Summary description of the Classfun.
</summary>
public class Classfun
{
private string Capstr;

Public Classfun ()
{
//
TODO: Add constructor logic here
//
}
public string Moneynumtocap (decimal Num)
{
String cap= "0 A three Woolu qi Ba Nine";
String numstr= "0123456789";
String moneynumstr=num.tostring ();
int Pint=moneynumstr.indexof (".");
int numint;

String Moneyint=null;
String Moneydec=null;
String Intstr=null;
String Moneycap=null;
String Moneyintstr=null;
String Moneydecstr=null;
Capstr=pint.tostring ();

if (pint!=-1)
{
String strarr= ".";
Char[] Chararr=strarr.tochararray ();
String[] Moneynumarr=moneynumstr.split (Chararr);
Moneyint=moneynumarr[0]. ToString ();
MONEYDEC=MONEYNUMARR[1]. ToString ();

}
Else
{
MONEYINT=MONEYNUMSTR;
moneydec= "00";
}

if (moneyint.length>16)
{
MessageBox.Show ("Numerical hyper-boundary");
}
Else
{
---process an integer part--------

for (int j=1;j<=moneyint.length;j++)
{
Moneyintstr=moneyint.substring (j-1,1);
for (int i=0;i<=9;i++)
{

Intstr=numstr.substring (i,1);
Moneycap=cap.substring (i,1);

if (MONEYINTSTR==INTSTR)
{

Switch (INTSTR)
{
Case "0":
Capstr=capstr+moneycap;
Break
Case "1":
Capstr=capstr+moneycap;
Break
Case "2":
Capstr=capstr+moneycap;
Break
Case "3":
Capstr=capstr+moneycap;
Break
Case "4":
Capstr=capstr+moneycap;
Break
Case "5":
Capstr=capstr+moneycap;
Break
Case "6":
Capstr=capstr+moneycap;
Break
Case "7":
Capstr=capstr+moneycap;
Break
Case "8":
Capstr=capstr+moneycap;
Break
Case "9":
Capstr=capstr+moneycap;
Break
}
}
}
numint=moneyint.length-j+1;
Switch (numint)
{
Case 16:
capstr=capstr+ "thousand million";
Break
Case 15:
capstr=capstr+ "Hundred million";
Break
Case 14:
capstr=capstr+ "Collect million";
Break
Case 13:
Capstr=capstr+ "million";
Break

Case 12:
capstr=capstr+ "thousand";
Break

Case 11:
capstr=capstr+ "Bai";
Break

Case 10:
capstr=capstr+ "Pick up";
Break

Case 9:
Capstr=capstr+ "billion";
Break

Case 8:
capstr=capstr+ "thousand";
Break

Case 7:
capstr=capstr+ "Bai";
Break

Case 6:
capstr=capstr+ "Pick up";
Break


Case 5:
Capstr=capstr+ "million";
Break

Case 4:
capstr=capstr+ "thousand";
Break
Case 3:
capstr=capstr+ "Bai";
Break
Case 2:
capstr=capstr+ "Pick up";
Break
Case 1:
capstr=capstr+ "Yuan";
Break

}

}

------deal with a small number of parts--
for (int j=1; j<=2; j + +)
{
Moneydecstr=moneydec.substring (j-1,1);

for (int i=0;i<=9;i++)
{
Intstr=numstr.substring (i,1);
Moneycap=cap.substring (i,1);
if (MONEYDECSTR==INTSTR)
{

Switch (INTSTR)
{
Case "0":
Capstr=capstr+moneycap;
Break
Case "1":
Capstr=capstr+moneycap;
Break
Case "2":
Capstr=capstr+moneycap;
Break
Case "3":
Capstr=capstr+moneycap;
Break
Case "4":
Capstr=capstr+moneycap;
Break
Case "5":
Capstr=capstr+moneycap;
Break
Case "6":
Capstr=capstr+moneycap;
Break
Case "7":
Capstr=capstr+moneycap;
Break
Case "8":
Capstr=capstr+moneycap;
Break
Case "9":
Capstr=capstr+moneycap;
Break
}
}
}


Switch (j)
{
Case 1:
capstr=capstr+ "angle";
Break
Case 2:
capstr=capstr+ "points";
Break

}

}

}

return capstr;
}








}
}




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.