This message was edited by Raadya at 2003-11-3 4:8:33
[pre]
Hi, I don't know good english, but I try help to you
here is a program for conversion any word-number to a digital form.
uses CRT;
var
cr,x,y,expnt:byte;
c:char;
delka,cislo:word;
slovo:string;
vysledek:word;
numbers:array[1..4] of string;
const
digits: array[0..20] of string=
'zero','one','two','three','four','five','six','seven','eight','nine', 'ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty';
digits2:[3..9] of string=
'thirty','forty','fifty','sixty','seventy','eighty','ninety';
begin
ClrScr;
Write ('What is the number? ');
readLN (slovo);
delka:=length(slovo);
cr:=1;
y:=1;
for x:=1 to 4 do numbers[x]:='';
{ this makes from word e.g. 'thirty-five' two words "thirty" and "five" '}
for x:=1 to delka do
begin
if (slovo[x]<>' ' OR (slovo[x]<>'-')) then
numbers[cr]:=numbers[cr]+slovo[x] else cr:=cr+1;
{ one didit ends with the mark <SPACE> or - }
end;
for x:=cr downto 1 do
begin
for y:=0 to 20 do
begin
if numbers[x]=digits[y] then
begin
vysledek:=vysledek+y*expnt;
expnt:=1;
end;
for y:=3 to 9 do
if numbers[x]=digits2[y] then vysledek:=vysledek+y*10;
if numbers[x]='hundert' then exp:=100;
end;
Writeln(' and in digitals is it: ', vysledek);
Writeln;
Writeln(' Press ENTER to end of this program');
ReadLN;
end.
I hope, it will go...
I write it in the school and I havent any shance to try it...
When you will have any questions, write to me at: cz609361@tiscali.cz
Bye
Radim as raadya here
[/pre]