For example: $112.30 - ONE HUNDRED AND TWELVE DOLLARS AND THIRTY CENTS!!!!
Solution (if you are not aware)
I was undergoing a training and the trainer asked this question. I suggested a general logic
divide the amount by 1000, 100, 10 respectively to get THOUSANDs, HUNDREDs and ONEs...
but he has given a simple logic in COBOL..
Here is the logic and just wanted to share with you....
define a variable
01 AMT PIC 9(5).9(2)
01 AMT-X redefines AMT.
05 AMT-THOUSANDS PIC X(2).
05 AMT-HUNDREDS PIC X(1).
05 AMT-TENS PIC X(1).
05 AMT-ONES PIC X(1).
05 AMT-DOT PIC X(1).
05 AMT-DECIMALS PIC X(2).
01 AMT-X redefines AMT.
05 AMT-THOUSANDS PIC X(2).
05 AMT-HUNDREDS PIC X(1).
05 AMT-TENS PIC X(1).
05 AMT-ONES PIC X(1).
05 AMT-DOT PIC X(1).
05 AMT-DECIMALS PIC X(2).
And little more code is required for validations if ‘0’s present in the respective field values..
Usually this is a subroutine in the existing systems just by passing the value we get the required....
Just thought to share the info with you...
Regards,
jayind