Convert digital strings to uppercase amount strings

xiaoxiao2021-03-06  66

// Convert the numeric string to a capital amount string

@ at

@ created 2004/11/15 19:37

@ param numeric string

@ return capital amount string

@ THROWS EXCEPTION

// The processable situation includes these digital forms: [.] [0.] [.0] [.3] [.32] [1.] [23]

Public string cncurrency (String snumber) THROWS EXCEPTION

{

String sunit = "Practitioner Yuan Pick up 佰 万 万 佰";

String Schinese = "Zi Zi Zun Lu Yu";

Int nunit; // Money unit subscript

Int nDOTPOS; // In the incoming number, the location of the decimal point

INT Nlen; // Length

INT nvalue; // Temporary value

INT i; // cycle variable

String sinteger; // integer part

String sdecimal; // decimal part

String ssuffix = ""; // suffix part

IF (snumber == null) throw new exception ("No password!");

// Get position where the decimal point is

ndotpos = snumber.indexof (".");

IF (ndotpos == -1) {

SINTEGER = (SNUMBER.EQUALS ("))?" 0 ": snumber;

SDECIMAL = "00";

} else {

Snumber = new stringbuffer (). Append ("0"). Append (snumber) .append ("00"). TOSTRING ();

ndotpos = snumber.indexof (".");

sinteger = snumber.substring (0, ndotpos);

SDECIMAL = snumber.substring (ndotpos 1) .substring (0, 2);

}

Stringbuffer sbChinese = new stringbuffer ();

/ / Start processing integer part

Nlen = sinteger.length ();

For (i = 0; i

0))

SBCHINESE.APPEND ("Yuan");

// Start processing of the fractional part

IF (SDECIMAL.EQUALS ("00")) {

Ssuffix = "whole";

} else {

Nvalue = integer.parseint (SDECIMAL.SUBSTRING (0, 1));

IF (nvalue! = 0) sbchinese.append (schinese.substring (nvalue-1, nvalue)). Append (SUNIT.SUBSTRING (1, 2));

Nvalue = integer.parseint (SDECIMAL.SUBSTRING (1, 2));

IF (nvalue! = 0) sbChinese.Append (Schinese.substring (nvalue-1, nvalue)). Append (SUNIT.SUBSTRING (0, 1));

}

// If the decimal part does not write anything,

// Return to Chinese Results

IF (sbchinese.length () == 0) Ssuffix = "Zero Yuan"; sbChinese.Append (SSUFFIX);

Return SbCHINESE.TOString ();

}

转载请注明原文地址:https://www.9cbs.com/read-90501.html

New Post(0)