引言
我想讨论一下我几年前在 C++ 中开发的一种编程技术,用于将数字金额转换为文字金额。我将其用于我为家乡美国俄亥俄州克利夫兰市的一位长期客户编写的支票簿登记簿程序中。这项技术是一个较大程序中的一个模块,该程序用于每周编写和签发支票,用于支付工资、税款、材料、办公用品、公用事业费用等等。多年来,它被证明非常可靠。该算法还可以用于协助打印法律合同、贷款文件、本票以及许多其他需要指定文字金额的事项。
我网站上可以看到完整的 C++ 程序代码。接下来,我将解释逻辑流程,以便于理解。
准备工作
在 C++ 源代码的开头,会定义常量,以便其余代码可以引用它们来完成各种任务。点击“打印支票”按钮后,将声明变量和对象。接下来,使用简单的 if-then 逻辑结构来测试是否已从支票簿登记簿屏幕中选择了一个支票簿登记簿记录。这是必需的,因为需要支票簿登记簿屏幕中的支票号码来帮助创建打印的支票。现在初始化支票和支票存根的变量。接下来,从当前显示屏幕的控件中检索以下项。这些项包括支票号码、供应商名称、发票描述、支票备忘录和付款日期。
下一步,必须打开到二进制支票簿登记簿数据文件“cbook.txt”的文件流。在这里,将进入一个 do-while 循环结构,以收集要支付的每张发票的数据。每张支票簿登记簿记录的支票号码将与当前数据录入屏幕中检索到的支票号码进行匹配。每条匹配的记录将检索特定供应商发票的日期、费用代码、发票号码、发票总额、提前付款折扣和净发票金额,这些发票将通过此支票支付。在此特定应用程序的支票存根上,最多只能有 10 张发票。每次通过 do-while 循环结构时,匹配的支票簿登记簿记录将被标记为已付款,并且净发票金额将被累加。此总额将成为要转换为文字金额的数字金额。
在验证从上面的 do-while 循环结构中至少找到一个匹配的支票号码后,净发票金额总额将在一个名为“totpay”的字符数组中指定。该字符数组将在片刻的转换到文字金额中得到广泛利用。但首先,必须打开到供应商二进制数据文件“vendor.txt”的文件流。这将是另一个 do-while 循环结构,它将当前显示屏幕中检索到的供应商名称与供应商数据文件中的名称进行匹配。供应商的街道、城市、州和邮政编码将在成功匹配后检索,然后使用一些简单的字符串操作进行格式化,以便最终打印在支票上。
核心部分
这里有一些字符数组集,它们定义了用于构建支票文字金额的某些文字组件。这些字符数组集中的每一个都将被分配一个特定的名称,以便叙述利用它们将数字金额转换为文字金额的软件开发算法。
1 2 3 4 5 6 7 8 9 10
|
char am1[] = "NINETY";
char am2[] = "EIGHTY";
char am3[] = "SEVENTY";
char am4[] = "SIXTY";
char am5[] = "FIFTY";
char am6[] = "FORTY";
char am7[] = "THIRTY";
char am8[] = "TWENTY";
|
上述字符数组内容根据要转换的数字金额小数点左侧的第二(2nd)和第五(5th)位数字,选择性地连接到文字描述变量。
这是 A 组。
1 2 3 4 5 6 7 8 9 10 11
|
char am9[] = "ONE";
char am10[] = "TWO";
char am11[] = "THREE";
char am12[] = "FOUR";
char am13[] = "FIVE";
char am14[] = "SIX";
char am15[] = "SEVEN";
char am16[] = "EIGHT";
char am17[] = "NINE";
|
上述字符数组内容根据要转换的数字金额小数点左侧的第一(1st)、第三(3rd)和第四(4th)位数字,选择性地连接到文字描述变量。
这是 B 组。
1 2 3
|
char am18[] = "THOUSAND";
|
在检测到“千位数字”(即要转换的数字金额小数点左侧的第四(4th)位)之后,将其连接到文字描述变量。
这是千位指示符。
1 2 3
|
char am19[] = "HUNDRED";
|
在检测到“百位数字”(即要转换的数字金额小数点左侧的第三(3rd)位)之后,将其连接到文字描述变量。
这是百位指示符。
此项不连接到文字描述变量,而是在处理结束时,在没有其他描述符连接到上述变量后为其赋值。
这是零指示符。
1 2 3 4 5 6 7 8 9 10 11 12
|
char am210[] = "TEN";
char am211[] = "ELEVEN";
char am212[] = "TWELVE";
char am213[] = "THIRTEEN";
char am214[] = "FOURTEEN";
char am215[] = "FIFTEEN";
char am216[] = "SIXTEEN";
char am217[] = "SEVENTEEN";
char am218[] = "EIGHTEEN";
char am219[] = "NINETEEN";
|
上述字符数组内容根据要转换的数字金额小数点左侧的第一(1st)和第四(4th)位数字,选择性地连接到文字描述变量。
这是 C 组。
开始构建
首先要做的就是用空格字符初始化 70 个字符的字符数组“verbal_amount”,以便算法将其更新,该算法将字符数组“totpay”中的数字金额转换为对应的文字金额。还将使用一个计数器变量“aa”来计算附加到字符数组“verbal_amount”中的字符数。
接下来,检查数字字符数组“totpay”中小数点左侧的第 5 位数字是否大于 0(开始结构“a”)。如果为真,则检查数字字符数组“totpay”中小数点左侧的第 5 位数字是否等于 1(开始结构“b”)。如果为真,则使用 **C 组** 根据数字字符数组“totpay”中小数点左侧的第 4 位数字,为“verbal_amount”字符数组分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
// if the 4th digit to the left of the decimal point is 0, then append
// "TEN" to the 'verbal_amount' array.
if(totpay[3] == 48) {
for(f=0; f<3; f++) verbal_amount[f] = am210[f];
aa=3;
}
// if the 4th digit to the left of the decimal point is 1, then append
// "ELEVEN" to the 'verbal_amount' array.
if(totpay[3] == 49) {
for(f=0; f<6; f++) verbal_amount[f] = am211[f];
aa=6;
}
// if the 4th digit to the left of the decimal point is 2, then append
// "TWELVE" to the 'verbal_amount' array.
if(totpay[3] == 50) {
for(f=0; f<6; f++) verbal_amount[f] = am212[f];
aa=6;
}
// if the 4th digit to the left of the decimal point is 3, then append
// "THIRTEEN" to the 'verbal_amount' array.
if(totpay[3] == 51) {
for(f=0; f<8; f++) verbal_amount[f] = am213[f];
aa=8;
}
// if the 4th digit to the left of the decimal point is 4, then append
// "FOURTEEN" to the 'verbal_amount' array.
if(totpay[3] == 52) {
for(f=0; f<8; f++) verbal_amount[f] = am214[f];
aa=8;
}
// if the 4th digit to the left of the decimal point is 5, then append
// "FIFTEEN" to the 'verbal_amount' array.
if(totpay[3] == 53) {
for(f=0; f<7; f++) verbal_amount[f] = am215[f];
aa=7;
}
// if the 4th digit to the left of the decimal point is 6, then append
// "SIXTEEN" to the 'verbal_amount' array.
if(totpay[3] == 54) {
for(f=0; f<7; f++) verbal_amount[f] = am216[f];
aa=7;
}
// if the 4th digit to the left of the decimal point is 7, then append
// "SEVENTEEN" to the 'verbal_amount' array.
if(totpay[3] == 55) {
for(f=0; f<9; f++) verbal_amount[f] = am217[f];
aa=9;
}
// if the 4th digit to the left of the decimal point is 8, then append
// "EIGHTEEN" // to the 'verbal_amount' array.
if(totpay[3] == 56) {
for(f=0; f<8; f++) verbal_amount[f] = am218[f];
aa=8;
}
// if the 4th digit to the left of the decimal point is 9, then append
// "NINETEEN" // to the 'verbal_amount' array.
if(totpay[3] == 57) {
for(f=0; f<8; f++) verbal_amount[f] = am219[f];
aa=8;
}
|
结束结构“b”。接下来,使用 **A 组** 根据数字字符数组“totpay”中小数点左侧的第 5 位数字,为“verbal_amount”字符数组分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
// if the 5th digit to the left of the decimal point is 2, then append
// "TWENTY" to the 'verbal_amount' array.
if(totpay[2] == 50) {
for(f=0; f<6; f++) verbal_amount[f] = am8[f];
aa=6;
}
// if the 5th digit to the left of the decimal point is 3, then append
// "THIRTY" to the 'verbal_amount' array.
if(totpay[2] == 51) {
for(f=0; f<6; f++) verbal_amount[f] = am7[f];
aa=6;
}
// if the 5th digit to the left of the decimal point is 4, then append
// "FORTY" to the 'verbal_amount' array.
if(totpay[2] == 52) {
for(f=0; f<5; f++) verbal_amount[f] = am6[f];
aa=5;
}
// if the 5th digit to the left of the decimal point is 5, then append
// "FIFTY" to the 'verbal_amount' array.
if(totpay[2] == 53) {
for(f=0; f<5; f++) verbal_amount[f] = am5[f];
aa=5;
}
// if the 5th digit to the left of the // decimal point is 6, then append
// "SIXTY" to the 'verbal_amount' array.
if(totpay[2] == 54) {
for(f=0; f<5; f++) verbal_amount[f] = am4[f];
aa=5;
}
// if the 5th digit to the left of the decimal point is 7, then append
// "SEVENTY" to the 'verbal_amount' array.
if(totpay[2] == 55) {
for(f=0; f<7; f++) verbal_amount[f] = am3[f];
aa=7;
}
// if the 5th digit to the left of the decimal point is 8, then append
// "EIGHTY" to the 'verbal_amount' array.
if(totpay[2] == 56) {
for(f=0; f<6; f++) verbal_amount[f] = am2[f];
aa=6;
}
// if the 5th digit to the left of the decimal point is 9, then append
// "NINETY" to the 'verbal_amount' array.
if(totpay[2] == 57) {
for(f=0; f<6; f++) verbal_amount[f] = am1[f];
aa=6;
}
|
开始结构“c”。如果数字字符数组“totpay”中小数点左侧的第 5 位数字不等于 1,则使用 **B 组** 根据数字字符数组“totpay”中小数点左侧的第 4 位数字,为“verbal_amount”字符数组分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
// if the 4th digit to the left of the decimal point is 1, then append
// "ONE" to the 'verbal_amount' array.
if(totpay[3] == 49) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am9[f];
aa=aa+4;
}
// if the 4th digit to the left of the decimal point is 2, then append
// "TWO" to the 'verbal_amount' array.
if(totpay[3] == 50) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am10[f];
aa=aa+4;
}
// if the 4th digit to the left of the decimal point is 3, then append
// "THREE" to the 'verbal_amount' array.
if(totpay[3] == 51) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am11[f];
aa=aa+6;
}
// if the 4th digit to the left of the decimal point is 4, then append
// "FOUR" to the 'verbal_amount' array.
if(totpay[3] == 52) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am12[f];
aa=aa+5;
}
// if the 4th digit to the left of the decimal point is 5, then append
// "FIVE" to the 'verbal_amount' array.
if(totpay[3] == 53) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am13[f];
aa=aa+5;
}
// if the 4th digit to the left of the decimal point is 6, then append
// "SIX" to the 'verbal_amount' array.
if(totpay[3] == 54) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am14[f];
aa=aa+4;
}
// if the 4th digit to the left of the decimal point is 7, then append
// "SEVEN" to the 'verbal_amount' array.
if(totpay[3] == 55) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am15[f];
aa=aa+6;
}
// if the 4th digit to the left of the decimal point is 8, then append
// "EIGHT" to the 'verbal_amount' array.
if(totpay[3] == 56) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am16[f];
aa=aa+6;
}
// if the 4th digit to the left of the decimal point is 9, then append
// "NINE" to the 'verbal_amount' array.
if(totpay[3] == 57) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am17[f];
aa=aa+5;
}
|
结束结构“c”。接下来,将“THOUSAND”附加到字符数组“verbal_amount”并结束结构“a”。
开始结构“d”。如果小数点左侧的第 5 位数字小于 1 且小数点左侧的第 4 位数字大于 0,则继续。使用 **B 组** 根据数字字符数组“totpay”中小数点左侧的第 4 位数字,为“verbal_amount”字符数组分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
// if the 4th digit to the left of the decimal point is 1, then append
// "ONE" to the 'verbal_amount' array.
if(totpay[3] == 49) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am9[f];
aa=aa+4;
}
// if the 4th digit to the left of the decimal point is 2, then append
// "TWO" to the 'verbal_amount' array.
if(totpay[3] == 50) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am10[f];
aa=aa+4;
}
// if the 4th digit to the left of the decimal point is 3, then append
// "THREE" to the 'verbal_amount' array.
if(totpay[3] == 51) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am11[f];
aa=aa+6;
}
// if the 4th digit to the left of the decimal point is 4, then append
// "FOUR" to the 'verbal_amount' array.
if(totpay[3] == 52) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am12[f];
aa=aa+5;
}
// if the 4th digit to the left of the decimal point is 5, then append
// "FIVE" to the 'verbal_amount' array.
if(totpay[3] == 53) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am13[f];
aa=aa+5;
}
// if the 4th digit to the left of the decimal point is 6, then append
// "SIX" to the 'verbal_amount' array.
if(totpay[3] == 54) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am14[f];
aa=aa+4;
}
// if the 4th digit to the left of the decimal point is 7, then append
// "SEVEN" to the 'verbal_amount' array.
if(totpay[3] == 55) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am15[f];
aa=aa+6;
}
// if the 4th digit to the left of the decimal point is 8, then append
// "EIGHT" to the 'verbal_amount' array.
if(totpay[3] == 56) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am16[f];
aa=aa+6;
}
// if the 4th digit to the left of the decimal point is 9, then append
// "NINE" to the 'verbal_amount' array.
if(totpay[3] == 57) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am17[f];
aa=aa+5;
}
|
接下来,将“THOUSAND”附加到字符数组“verbal_amount”并结束结构“d”。
开始结构“e”。如果小数点左侧的第 3 位数字大于 0,则继续。使用 **B 组** 根据数字字符数组“totpay”中小数点左侧的第 3 位数字,为“verbal_amount”字符数组分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
// if the 3rd digit to the left of the decimal point is 1, then append
// "ONE" to the 'verbal_amount' array.
if(totpay[4] == 49) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am9[f];
aa=aa+4;
}
// if the 3rd digit to the left of the decimal point is 2, then append
// "TWO" to the 'verbal_amount' array.
if(totpay[4] == 50) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am10[f];
aa=aa+4;
}
// if the 3rd digit to the left of the decimal point is 3, then append
// "THREE" to the 'verbal_amount' array.
if(totpay[4] == 51) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am11[f];
aa=aa+6;
}
// if the 3rd digit to the left of the decimal point is 4, then append
// "FOUR" to the 'verbal_amount' array.
if(totpay[4] == 52) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am12[f];
aa=aa+5;
}
// if the 3rd digit to the left of the decimal point is 5, then append
// "FIVE" to the 'verbal_amount' array.
if(totpay[4] == 53) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am13[f];
aa=aa+5;
}
// if the 3rd digit to the left of the decimal point is 6, then append
// "SIX" to the 'verbal_amount' array.
if(totpay[4] == 54) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am14[f];
aa=aa+4;
}
// if the 3rd digit to the left of the decimal point is 7, then append
// "SEVEN" to the 'verbal_amount' array.
if(totpay[4] == 55) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am15[f];
aa=aa+6;
}
// if the 3rd digit to the left of the decimal point is 8, then append
// "EIGHT" to the 'verbal_amount' array.
if(totpay[4] == 56) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am16[f];
aa=aa+6;
}
// if the 3rd digit to the left of the decimal point is 9, then append
// "NINE" to the 'verbal_amount' array.
if(totpay[4] == 57) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am17[f];
aa=aa+5;
}
|
接下来,将“HUNDRED”附加到字符数组“verbal_amount”并结束结构“e”。
现在检查数字字符数组“totpay”中小数点左侧的第 2 位数字是否大于 0(开始结构“f”)。如果为真,则检查数字字符数组“totpay”中小数点左侧的第 2 位数字是否等于 1(开始结构“g”)。如果为真,则使用 **C 组** 根据数字字符数组“totpay”中小数点左侧的第 1 位数字,为“verbal_amount”字符数组分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
// if the 1st digit to the left of the decimal point is 0, then append
// "TEN" to the 'verbal_amount' array.
if(totpay[6] == 48) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am210[f];
aa = aa + 4;
}
// if the 1st digit to the left of the decimal point is 1, then append
// "ELEVEN" to the 'verbal_amount' array.
if(totpay[6] == 49) {
for(f=0; f<6; f++) verbal_amount[f+aa+1] = am211[f];
aa = aa + 7;
}
// if the 1st digit to the left of the decimal point is 2, then append
// "TWELVE" to the 'verbal_amount' array.
if(totpay[6] == 50) {
for(f=0; f<6; f++) verbal_amount[f+aa+1] = am212[f];
aa = aa + 7;
}
// if the 1st digit to the left of the decimal point is 3, then append
// "THIRTEEN" to the 'verbal_amount' array.
if(totpay[6] == 51) {
for(f=0; f<8; f++) verbal_amount[f+aa+1] = am213[f];
aa = aa + 9;
}
// if the 1st digit to the left of the decimal point is 4, then append
// "FOURTEEN" to the 'verbal_amount' array.
if(totpay[6] == 52) {
for(f=0; f<8; f++) verbal_amount[f+aa+1] = am214[f];
aa = aa + 9;
}
// if the 1st digit to the left of the decimal point is 5, then append
// "FIFTEEN" to the 'verbal_amount' array.
if(totpay[6] == 53) {
for(f=0; f<7; f++) verbal_amount[f+aa+1] = am215[f];
aa = aa + 8;
}
// if the 1st digit to the left of the decimal point is 6, then append
// "SIXTEEN" to the 'verbal_amount' array.
if(totpay[6] == 54) {
for(f=0; f<7; f++) verbal_amount[f+aa+1] = am216[f];
aa = aa + 8;
}
// if the 1st digit to the left of the decimal point is 7, then append
// "SEVENTEEN" to the 'verbal_amount' array.
if(totpay[6] == 55) {
for(f=0; f<9; f++) verbal_amount[f+aa+1] = am217[f];
aa = aa + 10;
}
// if the 1st digit to the left of the decimal point is 8, then append
// "EIGHTEEN" to the 'verbal_amount' array.
if(totpay[6] == 56) {
for(f=0; f<8; f++) verbal_amount[f+aa+1] = am218[f];
aa = aa + 9;
}
// if the 1st digit to the left of the decimal point is 9, then append
// "NINETEEN" to the 'verbal_amount' array.
if(totpay[6] == 57) {
for(f=0; f<8; f++) verbal_amount[f+aa+1] = am219[f];
aa = aa + 9;
}
|
结束结构“g”。接下来,使用 **A 组** 根据数字字符数组“totpay”中小数点左侧的第 2 位数字,为“verbal_amount”字符数组分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
// if the 2nd digit to the left of the decimal point is 2, then append
// "TWENTY" to the 'verbal_amount' array.
if(totpay[5] == 50) {
for(f=0; f<6; f++) verbal_amount[f+aa+1] = am8[f];
aa=aa+7;
}
// if the 2nd digit to the left of the decimal point is 3, then append
// "THIRTY" to the 'verbal_amount' array.
if(totpay[5] == 51) {
for(f=0; f<6; f++) verbal_amount[f+aa+1] = am7[f];
aa=aa+7;
}
// if the 2nd digit to the left of the decimal point is 4, then append
// "FORTY" to the 'verbal_amount' array.
if(totpay[5] == 52) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am6[f];
aa=aa+6;
}
// if the 2nd digit to the left of the decimal point is 5, then append
// "FIFTY" to the 'verbal_amount' array.
if(totpay[5] == 53) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am5[f];
aa=aa+6;
}
// if the 2nd digit to the left of the decimal point is 6, then append
// "SIXTY" to the 'verbal_amount' array.
if(totpay[5] == 54) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am4[f];
aa=aa+6;
}
// if the 2nd digit to the left of the decimal point is 7, then append
// "SEVENTY" to the 'verbal_amount' array.
if(totpay[5] == 55) {
for(f=0; f<7; f++) verbal_amount[f+aa+1] = am3[f];
aa=aa+8;
}
// if the 2nd digit to the left of the decimal point is 8, then append
// "EIGHTY" to the 'verbal_amount' array.
if(totpay[5] == 56) {
for(f=0; f<6; f++) verbal_amount[f+aa+1] = am2[f];
aa=aa+7;
}
// if the 2nd digit to the left of the decimal point is 9, then append
// "NINETY" to the 'verbal_amount' array.
if(totpay[5] == 57) {
for(f=0; f<6; f++) verbal_amount[f+aa+1] = am1[f];
aa=aa+7;
}
|
结束结构“f”。如果小数点左侧的第 1 位数字大于 0 且小数点左侧的第 2 位数字不等于 1,则开始结构“h”。使用 **B 组** 根据数字字符数组“totpay”中小数点左侧的第 1 位数字,为“verbal_amount”字符数组分配描述符,如下所示。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
// if the 1st digit to the left of the decimal point is 1, then append
// "ONE" to the 'verbal_amount' array.
if(totpay[6] == 49) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am9[f];
aa=aa+4;
}
// if the 1st digit to the left of the decimal point is 2, then append
// "TWO" to the 'verbal_amount' array.
if(totpay[6] == 50) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am10[f];
aa=aa+4;
}
// if the 1st digit to the left of the decimal point is 3, then append
// "THREE" to the 'verbal_amount' array.
if(totpay[6] == 51) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am11[f];
aa=aa+6;
}
// if the 1st digit to the left of the decimal point is 4, then append
// "FOUR" to the 'verbal_amount' array.
if(totpay[6] == 52) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am12[f];
aa=aa+5;
}
// if the 1st digit to the left of the decimal point is 5, then append
// "FIVE" to the 'verbal_amount' array.
if(totpay[6] == 53) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am13[f];
aa=aa+5;
}
// if the 1st digit to the left of the decimal point is 6, then append
// "SIX" to the 'verbal_amount' array.
if(totpay[6] == 54) {
for(f=0; f<3; f++) verbal_amount[f+aa+1] = am14[f];
aa=aa+4;
}
// if the 1st digit to the left of the decimal point is 7, then append
// "SEVEN" to the 'verbal_amount' array.
if(totpay[6] == 55) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am15[f];
aa=aa+6;
}
// if the 1st digit to the left of the decimal point is 8, then append
// "EIGHT" to the 'verbal_amount' array.
if(totpay[6] == 56) {
for(f=0; f<5; f++) verbal_amount[f+aa+1] = am16[f];
aa=aa+6;
}
// if the 1st digit to the left of the decimal point is 9, then append
// "NINE" to the 'verbal_amount' array.
if(totpay[6] == 57) {
for(f=0; f<4; f++) verbal_amount[f+aa+1] = am17[f];
aa=aa+5;
}
|
结束结构“h”。如果上述代码中没有任何内容被转换为文字金额(由于上述连接编程未递增,“aa”计数器变量等于 0),则将 **零指示符** 赋值给“verbal_amount”字符数组。最后,在“verbal_amount”字符数组中跳过一个空格字符,然后附加“AND”。再跳过一个空格字符,然后附加数字字符数组“totpay”中的两位(2)分位字符,后跟“/100”。
结论
从上述叙述可以看出,应用程序开发可以节省大量时间和劳动力。当 tôi 创建软件时,我并不太在意它是否美观,只要它易于使用、可靠且速度合理即可。这才是商务人士真正关心的。我的开发者技能可以追溯到 20 世纪 90 年代初,当时 tôi 就开始设计商务软件。如果您想了解更多 về tôi 提供的服务,请通过 tôi 的软件开发商网站与 tôi 联系。