John Archer writes:
> I've been asked to see if there is any FREE s/w that will translate a dollar
> figure into English that would be
> suitable for a computer generated check. Callable by a program preferably
> Cobol.
John,
While the code below isn't exactly what you wanted, it's close enough so that
a COBOL programmer could modify it and put into use almost immediately.
The code is actually written in VB, which means that it is primarily written
in a simple English, and is used for translating the number of numeric seconds
a particular process is estimated to take into an English statement. In that,
it's actually more complicated than you need, so your version should be about
half as long. The code below allows the result to be stated in seconds,
minutes, hours, days, and years, thousands of years, millions of years, and
billion of years.
All you will need is cents, dollars, hundreds of dollars, thousands of
dollars, millions of dollars, and possibly billions of dollars.
Just as a matter of explanation, the code below is part of a graphical display
that calculates the time it would take for a computer to randomly draw, using
standard Monte Carlo techniques, a matrix thermodynamically more ordered than
the one observed in nature. The text that appears at the bottom of a
developing graph is of the form, with the numbers rounded off to the nearest
tenth of whatever scale value was chosen:
"Using this computer, the estimated time necessary to draw at least
one matrix colder than the actual data: 124.7 thousand million billion
billion years."
or
"Using this computer, the estimated time necessary to draw at least
one matrix colder than the actual data: 63.4 days."
The trick in this kind of programming is to first determine the general scale
that you'll be using (seconds, minutes, etc.) and then start from the largest
units you wish to support and divide them out until you have no remainder.
Wirt Atmar
========================================
esttime = 1 / prob * interval
tempchart.CurrentX = 3500
tempchart.CurrentY = 1700
tempchart.ForeColor = &H808080
tempchart.Print "Using this computer, the estimated time
necessary to draw at least one"
tempchart.CurrentY = 1900
tempchart.CurrentX = 3500
tempchart.Print "matrix colder than the actual data:";
If esttime < 2 * interval Then
tempchart.Print " essentially instantaneous"
GoTo MCcontinue
End If
If esttime < 60 Then
esttime = Int(esttime * 10) / 10
tempchart.Print esttime; "seconds."
GoTo MCcontinue
End If
If esttime < 3600 Then
esttime = Int(esttime * 10 / 60) / 10
tempchart.Print esttime; "minutes."
GoTo MCcontinue
End If
If esttime < 86400 Then
esttime = Int(esttime * 10 / 3600) / 10
tempchart.Print esttime; "hours."
GoTo MCcontinue
End If
If esttime < 31557600 Then
esttime = Int(esttime * 10 / 86400) / 10
tempchart.Print esttime; "days."
GoTo MCcontinue
End If
esttime = esttime / 31557600
Timetext = "years."
MCbillion:
If esttime > 10 ^ 9 Then
esttime = esttime / 10 ^ 9
Timetext = "billion " + Timetext
GoTo MCbillion
End If
MCmillion:
If esttime > 10 ^ 6 Then
esttime = esttime / 10 ^ 6
Timetext = "million " + Timetext
GoTo MCmillion
End If
MCthousand:
If esttime > 1000 Then
esttime = esttime / 10 ^ 3
Timetext = "thousand " + Timetext
GoTo MCthousand
End If
esttime = Int(esttime * 10) / 10
tempchart.Print esttime; Timetext
MCcontinue:
End If
tempchart.CurrentX = 600
tempchart.CurrentY = 1900
temp = 20
sigma = (20 - runavg) / runstd
GoSub GetProb
tempchart.CurrentX = 600
tempchart.CurrentY = 1650
temp = 10
sigma = (10 - runavg) / runstd
GoSub GetProb
End If
========================================
|