check writing


I'm working on a program that translates numbers into words (English). I have majority of the program done, but I am stuck on the main part. Would anyone give me a hint? im finding the problem when getting the rumbers to print past 10

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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
 //This program translates numbers into english description.
#include <iostream>
#include <string>
using namespace std;
//Creat the Class numbers that holds all the translations into english.
class Numbers
{
	private: 
	int number;
	static string one[];
	static string ten[];
	static string teen[];
	static string hundred[];
	static string thousand[];
	
	public:
	Numbers();
	//constructor
	Numbers(int num){setNum(num);};
	void setNum(int num){number = num;};
	void print();	
	//finish the class
};


string Numbers:: one[] = {" ", "one","two", "three", "four", "five", "six", "seven","eight","nine","ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
//string Numbers:: teen[] = {"eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
string Numbers:: ten[] = {"ten", "twenty", "thirty","fourty","fifty","sixty", "seventy", "eighty","ninty"};
string Numbers:: hundred[] = {"hundred"};
string Numbers:: thousand[] = {"thousand"};

void Numbers::print()
{
	//print the translation of the inputed number.
  if(number<0)
    {
        cout<<"minus ";
        Numbers(-number);
    }
    else if(number>=1000)
    {
        Numbers(number/1000);
        cout<<" thousand";
        if(number % 1000)
        {
            if(number % 1000 < 100)
            {
                cout << " and";
            }
            cout << " " ;
            Numbers(number % 1000);
        }
    }
    else if(number >= 100)
    {
        Numbers(number / 100);
        cout<<" hundred";
        if(number % 100)
        {
            cout << " and ";
            Numbers (number % 100);
        }
    }
    else if(number >= 20)
    {
        cout << ten[number / 10];
        if(number % 10)
        {
            cout << " ";
            Numbers(number % 10);
        }
    }
    else
    {
        cout<<one[number];
    }
}

//main program.
int main()
{
	int number;
	//print what the program does.
	cout << "This progam translates numbers into words ";
	cout << "for the purpose of writing checks. ";
	cout << "Entering a negative number automaticly terminates the progam. ";
	cout << endl;
	cout << "Enter the number you wish to translate: ";
	cin  >> number;
	
	//keep translating until a negative number is inputed
	while (number >= 0)
	{
		//create the number object
		Numbers n(number);
		//printe the english despcription
		n.print();
		//get another object
		cout << "\nEnter another number: ";
		cin  >> number;
	}
	
	return 0;
}
Line 67 works only for numbers < 100. The expression should look like

ten[(number / 10) % 10];

Note that line 71 and all similar lines do not have any effect whatsoever.
Topic archived. No new replies allowed.