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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83

#include<iostream>
#include<string>
using namespace::std;
class Numbers {
private:
int num;
public:
static string twoDigit[];
Numbers()
{ num=0;}
void setNumber(int number)
{ num=number;}
int getNumber()
{ return num;}
void print()
{
if(num>=1000)
{
int thousand;
thousand=(num%10000num%1000)/1000;
cout<<twoDigit[thousand]<<" thousand ";
}//end if
if(num>=100)
{
int hundred;
hundred=(num%1000num%100)/100;
cout<<twoDigit[hundred]<<" hundred and ";
}//end if
if(num>=0)
{
int ten;
ten=num%100;
cout<<twoDigit[ten]<<endl;
//cout<<ten<<endl;
}//end if
}//end void
};
string Numbers::twoDigit[100]={"zero","one","two","three","four","five","six","seven","eight","nine",
"ten","eleven","twelve", "thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen",
"twenty","twentyone","twentytwo","twentythree","twentyfour","twentyfive","twentysix",
"twentyseven","twentyeight","twentynine","thirty","thirtyone","thirtytwo","thirtythree",
"thirtyfour","thirtyfive","thirtysix","thirtyseven","thirtyeight","thirtynine",
"forty","fortyone","fortytwo","fortythree","fortyfour","fortyfive","fortysix","fortyseven",
"fortyeigth","fortynine","fifty","fiftyone","fiftytwo","fiftythree","fiftyfour","fiftyfive",
"fiftysix","fiftyseven","fiftyeight","fiftynine","sixty", "sixtyone","sixtytwo","sixtythree",
"sixtyfour","sixtyfive","sixtysix","sixtyseven","sixtyeight","sixtynine","seventy","seventyone",
"seventytwo","seventythree","seventyfour","seventyfive","seventysix","seventyseven",
"seventyeight","seventynine","eighty","eightyone","eightytwo","eightythree","eightyfour",
"eightyfive","eightysix","eightyseven","eightyeight","eightynine","ninety","ninetyone",
"ninetytwo","ninetythree","ninetyfour","ninetyfive","ninetysix","ninetyseven",
"ninetyeight","ninetynine"};
int main ()
{
int number;
Numbers conversion;
cout<<"Enter a number between the range of 09999 and the program"<<endl<<"will convert it to words."<<endl;
cin>>number;
if(number<0number>9999)
{
cout<<"Error.Number is out of range."<<endl;
cout<<"Enter a number between the range of 09999 and the program"<<endl<<"will convert it to words."<<endl;
cin>>number;
}
conversion.setNumber(number);
conversion.print();
system("pause");
return 0;
}
