#include "ntw.h"
unsigned long ntw::getNum()
{
return varNum;
}
string ntw::getWord()
{
return Nword;
}
void ntw::u20( unsigned long number, bool one )
{
switch( number )
{
case 1:
if( one )
{
Nword += "eins";
}
else
{
Nword += "ein";
}
break;
case 2: Nword += "zwei"; break;
case 3: Nword += "drei"; break;
case 4: Nword += "vier"; break;
case 5: Nword += "fünf"; break;
case 6: Nword += "sechs"; break;
case 7: Nword += "sieben"; break;
case 8: Nword += "acht"; break;
case 9: Nword += "neun"; break;
case 10: Nword += "zehn"; break;
case 11: Nword += "elf"; break;
case 12: Nword += "zwölf"; break;
case 13: Nword += "dreizehn"; break;
case 14: Nword += "vierzehn"; break;
case 15: Nword += "fünfzehn"; break;
case 16: Nword += "sechszehn"; break;
case 17: Nword += "siebzehn"; break;
case 18: Nword += "achtzehn"; break;
case 19: Nword += "neunzehn"; break;
default: Nword += "-Fehler-"; break;
}
}
//*******************************************************
void ntw::tens( unsigned long number )
{
switch( number / 10 )
{
case 2: Nword += "zwanzig"; break;
case 3: Nword += "dreissig"; break;
case 4: Nword += "vierzig"; break;
case 5: Nword += "fünfzig"; break;
case 6: Nword += "sechzig"; break;
case 7: Nword += "siebzig"; break;
case 8: Nword += "achtzig"; break;
case 9: Nword += "neunzig"; break;
default: Nword += "-Fehler-"; break;
}
}
//*******************************************************
void ntw::u100( unsigned long number, bool one )
{
if( number < 20 )
{
u20( number, one );
}
else if( number % 10 )
{
u20( number % 10, false );
Nword += "und";
tens( number );
}
else
{
tens( number );
}
}
//*******************************************************
void ntw::u1000( unsigned long number, bool one )
{
if( number < 100 )
{
u100( number, one );
}
else if( number % 100 )
{
u20( number / 100, false );
Nword += "hundert";
u100( number % 100, one );
}
else
{
u20( number / 100, false );
Nword += "hundert";
}
}
//*******************************************************
void ntw::thousand( unsigned long number )
{
if( number >= 1000 )
{
u1000( number / 1000, false );
Nword += "tausend";
}
if( number % 1000 )
{
u1000( number % 1000, true );
}
}
//*******************************************************
void ntw::million( unsigned long number )
{
if( number >= 1000000 )
{
int mil = number / 1000000;
if( mil == 1 )
{
Nword = "einemillion";
}
else
{
u1000( mil, false );
Nword += "millionen";
}
number %= 1000000;
}
thousand( number );
}
//*******************************************************
void ntw::milliard( unsigned long number )
{
if( number >= 1000000000 )
{
int mil = number / 1000000000;
if( mil == 1 )
{
Nword += "einemilliarde";
}
else
{
u1000( mil, false );
Nword += "milliarden";
}
number %= 1000000000;
}
million( number );
}
//*******************************************************
string ntw::NumToWord( unsigned long number )
{
varNum = number;
if( number == 0 )
{
Nword = "Null";
}
else
{
milliard( number );
}
Nword[0] = toupper( Nword[0] );
return Nword;
}
//*******************************************************