如何添加“和”在将数字转换为货币字数之前的最后两位数字 [英] How to add "and" before last two digits while converting number to words for currency

查看:84
本文介绍了如何添加“和”在将数字转换为货币字数之前的最后两位数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前的输出:

仅两个LACS一千八百个/ -



我想要跟随输出:

两个LACS一千八百和六个/ -



我将数字转换成单词的公式是:



 numbervar RmVal:=  0 ; 
numbervar Amt:= 0 ;
numbervar pAmt:= 0 ;
stringvar InWords:= ;
Amt:=({DtBHeader.GrandTotal});
如果 Amt > 10000000 然后RmVal:= truncate(Amt / 10000000);
如果 Amt = 10000000 则RmVal:= 1 ;
如果 RmVal = 1
InWords:= InWords + + towords(RmVal, 0 )+ crore
else
如果 RmVal > 1 则InWords:= InWords + + towords(RmVal, 0 )+ crores;

Amt:= Amt - Rmval * 10000000 ;
如果 Amt > 100000 然后RmVal:= truncate(Amt / 100000);
如果 Amt = 100000 则RmVal:= 1 ;
如果 RmVal > = 1 then
InWords:= InWords + + towords(RmVal, 0 )+ lacs;

Amt:= Amt - Rmval * 100000 ;
如果 Amt > 0 然后InWords:= InWords + + towords(truncate(Amt), 0 );
pAmt:=(Amt - truncate(Amt))* 100 ;
如果 pAmt > 0 然后
InWords:= InWords + + towords(pAmt, 0 )+ 仅限paisa / -
else
InWords:= InWords + 仅/ - ;
UPPERCASE(InWords)

解决方案

得到正确答案:



 numbervar RmVal:=  0 ; 
numbervar Amt:= 0 ;
numbervar pAmt:= 0 ;
stringvar Inwards:= ;
numbervar totalAmt;
totalAmt:= Sum({DtBHeader.GrandTotal});
Amt:= totalAmt;

如果 Amt > = 10000000 然后
RmVal:= truncate(Amt / 10000000);
如果 RmVal = 1
Inwards:= Inwards + + towords(RmVal, 0 )+ crore
else
如果 RmVal > 1
Inwards:= Inwards + + towords(RmVal, 0 )+ crores;
Amt:= Amt - Rmval * 10000000 ;

RmVal:= 0 ;
如果 Amt > = 100000 then
RmVal:= truncate(Amt / 100000);
如果 RmVal = 1
Inwards:= Inwards + + towords(RmVal, 0 )+ lakh
否则
如果RmVal > 1 然后
内向:=向内+ + ToWords(RmVal, 0 )+ lakhs;
Amt:= Amt - Rmval * 100000 ;

RmVal:= 0 ;
如果 Amt > = 1000 then
RmVal:= truncate(Amt / 1000);
如果 RmVal = 1
Inwards:= Inwards + + towords(RmVal, 0 )+
否则
如果 RmVal > 1 然后
Inwards:= Inwards + + towords(RmVal, 0 )+ ;
Amt:= Amt - RmVal * 1000 ;

RmVal:= 0 ;
如果 Amt > = 100 then
RmVal:= truncate(Amt / 100);
如果 RmVal = 1
Inwards:= Inwards + + towords(RmVal, 0 )+ 100和
否则
if RmVal > 1 然后
Inwards:= Inwards + + towords(RmVal, 0 )+ 百和;
Amt:= Amt - RmVal * 100 ;


如果 Amt > 0 然后
Inwards:= Inwards + + towords(truncate(Amt), 0 );

pAmt:=(Amt - truncate(Amt))* 10 ;

如果 pAmt > 0 然后
内向:=向内+ + towords(pAmt , 0 )+ 仅限paisa / -
else
Inwards:= Inwards + only / - ;

UPPERCASE(内向)





输出:NINETEEN成千上万,仅七十七 -


My current output:
TWO LACS ONE THOUSAND EIGHT HUNDRED SIX ONLY/-

I want following output:
TWO LACS ONE THOUSAND EIGHT HUNDRED AND SIX ONLY/-

My formula for currency conversion of numbers to words is:

numbervar RmVal:=0; 
numbervar Amt:=0; 
numbervar pAmt:=0; 
stringvar InWords :=""; 
Amt := ({DtBHeader.GrandTotal}); 
if Amt > 10000000 then RmVal := truncate(Amt/10000000); 
if Amt = 10000000 then RmVal := 1; 
if RmVal = 1 then 
InWords := InWords + " " + towords(RmVal,0) + " crore" 
else 
if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + " crores";

Amt := Amt - Rmval * 10000000; 
if Amt > 100000 then RmVal := truncate(Amt/100000); 
if Amt = 100000 then RmVal := 1; 
if RmVal >=1 then 
InWords := InWords + " " + towords(RmVal,0) + " lacs";

Amt := Amt - Rmval * 100000; 
if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0); 
pAmt := (Amt - truncate(Amt)) * 100; 
if pAmt > 0 then 
InWords := InWords + " and " + towords(pAmt,0) + " paisa only/-" 
else 
InWords :=  InWords  + " only/-"; 
UPPERCASE(InWords)

解决方案

Got the correct answer:

numbervar RmVal:=0; 
numbervar Amt:=0; 
numbervar pAmt:=0; 
stringvar Inwards :=" ";
numbervar totalAmt;
totalAmt := Sum ({DtBHeader.GrandTotal});
Amt := totalAmt;

if Amt >= 10000000 then
    RmVal := truncate(Amt/10000000); 
if RmVal = 1 then 
    Inwards := Inwards + " " + towords(RmVal,0) + " crore" 
else 
    if RmVal > 1 then 
        Inwards := Inwards + "  " + towords(RmVal,0) + " crores";
Amt := Amt - Rmval * 10000000;

RmVal := 0;
if Amt >= 100000 then 
    RmVal := truncate(Amt/100000); 
if RmVal = 1 then 
    Inwards := Inwards + "  " + towords(RmVal,0) + " lakh"
Else
    If RmVal > 1 then 
        Inwards := Inwards + "  " + ToWords(RmVal,0) + " lakhs";
Amt := Amt - Rmval * 100000;

RmVal := 0;
if Amt >= 1000 then 
    RmVal := truncate(Amt/1000);
if RmVal =1 then 
    Inwards := Inwards + "  " + towords(RmVal,0) + " thousand"
Else
    if RmVal > 1 then 
        Inwards := Inwards + "  " + towords(RmVal,0) + " thousand ";
Amt := Amt - RmVal * 1000;

RmVal := 0;
if Amt >= 100 then 
    RmVal := truncate(Amt/100);
if RmVal =1 then 
    Inwards := Inwards + " " + towords(RmVal,0) + " hundred and"
Else
    if RmVal > 1 then 
        Inwards := Inwards + " " + towords(RmVal,0) + " hundred and";
Amt := Amt - RmVal * 100;

        
if Amt > 0 then 
    Inwards := Inwards + " " + towords(truncate(Amt),0);

pAmt := (Amt - truncate(Amt)) * 10;

if pAmt > 0 then 
    Inwards := Inwards + " and " + towords(pAmt,0) + " paisa only /-" 
else 
    Inwards := Inwards + " only /-";

UPPERCASE(Inwards) 



OUTPUT: NINETEEN THOUSAND FOUR HUNDRED AND SEVENTY-SEVEN ONLY /-


这篇关于如何添加“和”在将数字转换为货币字数之前的最后两位数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆