Help reading numbers to written form

Pages: 12
Hey everyone I need some help with this code. I need to get the a number and have it in written form. Like 1 turns to one. 2 turns to two and so on.

Here is my code:
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>

using namespace std;

double userInput;
double number;
double fraction;
string one [] = {"Zero", "One" , "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine","Ten",
						"Eleven", "Twelve", "Thirteen","Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
string tens [] = {"", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"};
string huns [] = {"","Hundred", "Thousand", "Million"};
int num[10];
int frac[5];
double length = 0;
int x = 0, n = 0, f = 0;
int ones = 0, ten = 0, hun = 0;  
string result;


void getNumber ()
{
//getNumber gets the number and splits into three parts
//and stores it in an array
	
	n = (int)number;			//cast number into a int and then store it in n
	for (x = 0; x < 10; x++)	//runs a for loop to set the numbers into num[]  
	{
		num[x] = n % 1000;		//gets the remandier of the number and stores into the array num
		n = n / 1000;			//then divide by 1000 to get rid of the last three numbers  
	}							//repeats until the number is 0
}
void getDecimal ()
{
//getDecimal and makes it a int and stores the 
//decimal in an array
	if(fraction < 1 && fraction >= .00)	//sees if fraction is from .99 or from .00 to complete the rest of code
	{
		fraction = fraction * 100;		//multiples the fraction by 100 to get rid of the decimal
		f = (int)fraction;				//cast fraction into int and stores in f
		for (x = 0; x < 4; x++)			//runs for loop and stores the numbers into frac[]
		{
			frac[x] = f % 10;			//gets the remandier of the number and stores it into the array
			f = f / 10;					//then divides by 10 to get next number 
		}								//repeats untill it is 0

	}
}
void getToWords ()
{
//getToWords takes the number and decimal was stored in the array
//and runs through whiles statement to get the written form
	x = 10;
	while(x > -1)									
	{
		hun = num[x] / 100;						//in the loop takes the number of one of the numbers and divide by 100 to get the first number and stores it in hun
		ten = (num[x] /10)% 10;					//then takes the number again divide by 10 and gets the remandier of the num and gets the second number and stores it into ten
		ones = (num[x] % 10);					//then takes it the number again and gets the remandier of it and stores it into one.

		if (hun > 0)							//checks if the hun is more than 1
		{
			result.append(one[hun] + huns[1]);	//then appends then number to the string to result  
			cout << " ";						//also gets the hundred from the array since its from the the first number
		}
		
		if (ten == 0 && ones == 0)				//see if the number for ten and one is equal to zero 
		{
												//doesn't do anything becuase the number will be 100, 200, 300 etc.
		}

		if (ten == 1)							//if the number is ten equal to 1
		{
			result.append(one[ten * 10 + ones]);//ten time ones to get the teen problem and get it from array one and append it to the result
		}
		
		if (ten > 1 && ones >= 1)				//checks if then is greater then 1 and one is greater or equal to one
		{
			result.append(tens[ten] + one[ones]);//then get ten from the array and the join the one with it and append it to the result
		}

		else if (ten > 1)						//check if ten is greater than 1
		{
			result.append(tens[ten]);			//then get the ten from the array and append it to the result
		}

		if (ones >= 1 && ten == 0)				//if one is greater or equal to 1 and ten is equal to 0 then it gets the just the one number
		{
			result.append(one[ones]);			//get one from the array and append it to the result
		}
		x--;									//then x goes down to finished the loop
	}

	cout << result;	
}

int main()
{
	cout << "Ryan Cloud\nThis is The Written number project\n"; 
	//get a number
	//turn number to word form
	//display word form
	

	
	// ask the user to input a dollar amount
	cout << "\nEnter a Dollar amount\n";
	cin >> userInput; 
	

	fraction = modf(userInput, &number);
	// This seperates the number and the decimal into 2 variables. 
	//Number gets just the number and fraction just gets the decimal point from it.

	getNumber ();
	getToWords ();
	//getDecimal (); 

	
	return 0;
}
You are missing the part where you ask a question.
I like your comments. Now whats your problem? I'm sure not gonna read through all that looking for some possibly obscure error of yours.
No I ask the question in line 108.
Well my problem as if right now is getting that number and have it reading out correclty. Like I get the number, but only if it is 9 digits or maybe even 7 the whole program shuts down. Also I dont know exactly how to have the millions, thousands, hundreds etc to go also.
And all the comments are for me so I know what im doing and not just look at and forget what does what. It just helps knowing where it is and what excatly is it doing. Plus it makes my teacher happy
Well, first off. Why are all your variables global? And why are all your functions getSomething, but return no value...? Where exactly is the problem code? I still don't want to examine all this. And your comments are too wordy IMO. I personally like comments to be concise and straight to the point
I just made them all global I really wouldnt think that would be a problem. Well I am getting number and doing stuff with it. So whats the point of having not void. I can just put it in the int main and call it from there. Yeah I know my comments are way to wordy, its really bad. Im going to cut them down, but as if right now I have so I know what is doing what.
Well thats my problem I don't know where exactly it is. Well ive updated it since when I posted this.
Now if I get a number that is 9 digits it will close down, but it can do any number below that or after nine. Also I cant get the decimal to print out either with my updated code.
I think I have the answer but I when about it a little differently. What I did is process the number just like you or I read it.
I broke the number into blocks of hundreds and then added the billion, million and etc..
Example:
190,984,387
divide by 1,000,000 -> 190
Then have a function that handles hundreds.
Build a string as you go:
string = One hundred Ninety
string.append("Million")
Next when you get back from that make the new number 190,984,387-190,000,000 = 984,378.
Now divide by 1,000 -> 984
Then have the hundred function process 984.
string.append("Nine hundred eighty four")
string.append("Thousand");
984,378-984*1,000 = 378
Process 378
string.append("Three hundred Seventy eight")

cout << string << endl;
One hundred Ninety Million Nine hundred eighty four Thousand Three hundred Seventy eight

I don't know if I made any sense so here is a snippet
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
int main()
{
  double    number(0),
            fraction(0),
            userInput(0);
  string    ans;
  uint64_t  num(0);
  cout << "Ryan Cloud\nThis is The Written number project\n";
  cout << "\nEnter a Dollar amount\n";
  if ( cin >> userInput ) {
     fraction = modf(userInput, &number);
     for ( int i(0); i < 3; i++) {
        num = number/divs[i];
        if ( num ){
           findHun(num,ans);
           ans += huns[i];
           number -= num*divs[i];
        }
     }
     findHun(number,ans);
     cout << ans << endl;
  }
  else {
    cout << "Bad number" << endl;
  }
  return 0;
}
Ryan Cloud
This is The Written number project

Enter a Dollar amount
999999999
Nine Hundred Ninety Nine Million Nine Hundred Ninety Nine Thousand Nine Hundred Ninety Nine 


Edit: I didn't do anything with the decimal. Changed int num(0) to uint64_t num(0).
Last edited on
It's alright to help people with homework, but why give them the answer? Chances are, OP is just gonna copy pasta your code, and turn it in without learning anything
Understand. Just gave a small hint. I only added +/- 7 lines of code from what he posted to point him in a direction. There is another 20 lines that make it work. It doesn't look like what is there is going to work. Like what if he entered 2,002,000. His % would return 0 and he would start to lose digits.
Last edited on
Ok yeah that did make a little help. Yeah I just have problems actually getting the number into written form. Well im also supposed to have the decimal added on there.
I wouldn't to copy and pasta that code. I would like to do everything myself. I am only asking for help and hints, and he did help me. I think lol. Im not to sure yet, but ill let you. Thanks for the help ResidentBiscuit. I might be back idk yet so yeah
ok im still lost
1) if userInput is 9 digits long the whole program crashes
2)I still can't get the millions and thousands etc

if someone could point me in a good direction on how to fix those that would be great.

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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>

using namespace std;

double userInput;
double number;
double fraction;
string one [] = {"Zero", "One" , "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine","Ten",
						"Eleven", "Twelve", "Thirteen","Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
string tens [] = {"error", "erorr", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"};
string huns [] = {"","Hundred", "Thousand", "Million", "Billion"};
int num[10];
int frac[2];
double length = 0;
int x = 0, n = 0, f = 0, d = 0;
int ones = 0, ten = 0, hun = 0, tths = 0, hths = 0;  
string result;

void getNumber ()
{
//getNumber gets the number and splits into three parts
//and stores it in an array by modulo and dividing to get
//three parts untill number is 0
	
	n = (int)number;			
	for (x = 0; x < 10; x++)	  
	{
		num[x] = n % 1000;		
		n = n / 1000;
	}
}
void getDecimal ()
{
//getDecimal and sees if fraction is from .99 or from .00 and
//makes it a int by multiplying by 100 and stores the decimal in frac[] untill fraction is 0
	if(fraction < 1 && fraction >= .00)	
	{
		fraction = fraction * 100;		
		f = (int)fraction;				
		for (x = 0; x < 2; x++)			
		{
			frac[x] = f % 10;			
			f = f / 10;					 
		}								

	}
}
void getToWords ()
{
//getToWords takes the number and decimal was stored in the array
//and prints off the number it holds
//gets the number for each postion and stores it and repeats this untill
//the number it gets the result and prints it off
	x = sizeof num / sizeof(int);
	while(x > -1)									
	{
		hun = num[x] / 100;						
		ten = (num[x] /10)% 10;					
		ones = (num[x] % 10);					
		tths = frac[1] % 10;					
		hths = frac[0] % 10;

		if (hun > 0)							
		{
			result.append(one[hun] + " "+ huns[1] + " ");	
		}
		
		if (ten == 0 && ones == 0)				 
		{
												
		}

		if (ten == 1)							
		{
			result.append(one[ten * 10 + ones] + " ");
		}
		
		if (ten > 1 && ones >= 1)				
		{
			result.append(tens[ten] + " " + one[ones] + " ");
		}

		else if (ten > 1)						
		{
			result.append(tens[ten] + " ");			
		}

		if (ones >= 1 && ten == 0)				
		{
			result.append(one[ones] + " ");			
		}
		x--;									
	}

	d = sizeof frac / sizeof(int);
	while (d > 1)
	{
		if (tths == 0 && hths == 0)					
		{
			result.append("No cents");				
		}
		else if (hths >= 1 && tths == 0)					
		{
			result.append(one[hths] + " ");				
		}
		else if (tths == 1)								
		{
			result.append(one[tths * 10 + hths] + " ");	
		}
		else if (tths > 1 && hths >= 1)					
		{
			result.append(tens[tths] + " " + one[hths] + " "); 
		}
		else if (tths > 1 && hths == 0)							
		{
			result.append(tens[tths] + " ");				
		}
		d--;										
	}

	cout << result << "\n";	
}

int main()
{
	cout << "Ryan Cloud\nThis is The Written number project\n"; 
	//get a number
	//turn number to word form
	//display word form
	
	// ask the user to input a dollar amount
	cout << "\nEnter a Dollar amount\n";
	cin >> userInput; 
	
	if(userInput > 0)
	{
	fraction = modf(userInput, &number);
	// This seperates the number and the decimal into 2 variables. 
	//Number gets just the number and fraction just gets the decimal point from it.

	getNumber ();
	getDecimal (); 
	getToWords ();
	}
	else if (userInput == 0)
	{
		cout << one[0] << "\n";
	}
	else
	{
		cout << "Error\n";
	}
	return 0;
}
You are almost there!
1) if userInput is 9 digits long the whole program crashes

A number greater than 9 digits is larger than what a 32-bit integer can hold. So don't cast into a int cast to a long long to get 64-bit. That will allow you to get to ~18 digits (that said you only are coded to go to the billions so make changes if you want to go there). Look at n (two lines of code have to change).
2)I still can't get the millions and thousands etc

You need to append the "huns value" you are in to the end of the result after you create the hundred group.
Three lines of code have to change and five lines added for this to work.

Other things:
1. You only need to loop over the length of huns for x, because you don't do trillions quadrillion, quintillion, sextillion and etc...
2. In getToWords, your while loop should not start at 10, that is outside the range of num. Max index of num is 9.
3. After you have this "working", you are going to need to (I think) change the cin from a double to a string and split the string into number and fraction. Because you are going to get this error.
 ./a.out
Ryan Cloud
This is The Written number project

Enter a Dollar amount
100.10
User entered: 100.1
One Hundred  and Nine cents
This is a function of how a floating pointer number is stored in the computer i.e. 100.1 is stored as 100.09999999999999999 because .09 can not be represented as the sum of inverse powers of 2.
This is why 0.5 works because it is 1/2 or 1 over 2 to the power of 1.
./a.out
Ryan Cloud
This is The Written number project

Enter a Dollar amount
100.5
User entered: 100.5
One Hundred  and Fifty cents

But like I said, get the major part working. Then you can tackle issue #3 and globals and anything else you want to clean up.

Think about it.
Hope this helps.
histrungalot thank you for the help!!!
I think i got what to do now!! Thank you!!!
Hey im still having the problems with the huns. Im lost on it
Did you change anything from what you have posted above?
Yeah I've changed it quite a bit

Here is the code for now:

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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>

using namespace std;

double userInput;
double number;
double fraction;
string one [] = {"Zero", "One" , "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine","Ten",
						"Eleven", "Twelve", "Thirteen","Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
string tens [] = {"error", "erorr", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"};
string huns [] = {"","Hundred", "Thousand", "Million", "Billion", "Trillion", "Quadrillion", "Quintillion", "Sextillion"};
int num[100];
int frac[2];
double length = 0, getHun, h, p;
int x = 0, n = 0, f = 0, d = 0;
int ones = 0, ten = 0, hun = 0, tths = 0, hths = 0;  
string result, hunsGroup;


void getLength ()
{
//Gets the length of the number by log10 and 1 since it is one number short
	length = log10(number);
	length = length + 1;
	length = (int)length;
}
void getNumber ()
{
//getNumber gets the number and splits into three parts
//and stores it in an array by modulo and dividing to get
//three parts untill number is 0
	
	n = (int)number;			
	for (x = 0; x < length; x++)	  
	{
		num[x] = n % 1000;	
		n = n / 1000;
		if (n == 0)
		{
			break;
		}
	}
}
void getDecimal ()
{
//getDecimal and sees if fraction is from .99 or from .00 and
//makes it a int by multiplying by 100 and stores the decimal in frac[] untill fraction is 0
	if(fraction < 1 && fraction >= .00)	
	{
		fraction = fraction * 100;		
		f = (int)fraction;	

		for (x = 0; x < 2; x++)			
		{
			frac[x] = f % 10;			
			f = f / 10;					 
		}	

	}
}
void getHuns ()
{
//This gets the to check how many times the number gets divided into three parts
//to see what hundred place it is in.
	for (x = 0; x < length; x++)	  
	{	
		number = ((int)number % 1000) / 1000;
		getHun++;
	}
	getHun = getHun / 3;
	p = modf(getHun, &h);
	if(p < 1 && p > 0)
	{
		h = h + 1;
	}
	cout << huns[(int)h] << "\n";
	h--;
}
void getToWords ()
{
//getToWords takes the number and decimal was stored in the array
//and prints off the number it holds
//gets the number for each postion and stores it and repeats this untill
//the number it gets the result and prints it off
	x = (int)length;
		while(x > -1)
		{
			hun = num[x] / 100;						
			ten = (num[x] /10)% 10;					
			ones = (num[x] % 10);					
			tths = frac[1] % 10;					
			hths = frac[0] % 10;

			if (hun > 0)							
			{
				result.append(one[hun] + " " + huns[1] + " ");
			}
		
			if (ten == 0 && ones == 0)				 
			{							
			}

			 if (ten == 1)							
			{
				result.append(one[ten * 10 + ones] + " ");
			}
		
			else if (ten > 1 && ones >= 1)				
			{
				result.append(tens[ten] + " " + one[ones] + " ");
			}

			else if (ten > 1)						
			{
				result.append(tens[ten] + " ");	
			}

			else if (ones >= 1 && ten == 0)				
			{
				result.append(one[ones] + " ");
			}
			//result.append(huns[(int)h] + " ");
			h--;
			x--;
		}

	d = sizeof frac / sizeof(long);
	while (d > 1)
	{
		if (tths == 0 && hths == 0)					
		{
			result.append("No cents");				
		}
		else if (hths >= 1 && tths == 0)					
		{
			result.append(one[hths] + " Cents");				
		}
		else if (tths == 1)								
		{
			result.append(one[tths * 10 + hths] + " Cents");	
		}
		else if (tths > 1 && hths >= 1)					
		{
			result.append(tens[tths] + " " + one[hths] + " Cents"); 
		}
		else if (tths > 1 && hths == 0)							
		{
			result.append(tens[tths] + " Cents");				
		}
		d--;										
	}
	cout << result << "\n";	
}

int main()
{
	cout << "Ryan Cloud\nThis is The Written number project\n"; 
	//get a number
	//turn number to word form
	//display word form
	
	// ask the user to input a dollar amount
	cout << "\nEnter a Dollar amount\n";
	cin >> userInput; 
	
	if(userInput > 0)
	{
	fraction = modf(userInput, &number);
	// This seperates the number and the decimal into 2 variables. 
	//Number gets just the number and fraction just gets the decimal point from it.
	getLength ();
	getNumber ();
	getDecimal ();
	getHuns ();
	getToWords ();
	}
	else if (userInput == 0)
	{
		cout << one[0] << "\n";
	}
	else
	{
		cout << "Error\n";
	}
	return 0;
}
99% there, so take a look. Test it to see what the largest number it can take is.
Look for the lines that say CHANGED or Added.
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>
#include <stdint.h>

using namespace std;

double userInput;
double number;
double fraction;
string one [] = {"Zero", "One" , "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine","Ten",
						"Eleven", "Twelve", "Thirteen","Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
string tens [] = {"error", "erorr", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"};
// CHANGED
string huns [] = {"Hundred ", "Thousand ", "Million ", "Billion ","Trillion ", "Quadrillion ", "Quintillion ", "Sextillion "};
int num[10];
int frac[2];
double length = 0;
int x = 0, f = 0, d = 0;
// CHANGED
long long n(0);
int ones = 0, ten = 0, hun = 0, tths = 0, hths = 0;  
string result;

void getNumber ()
{
//getNumber gets the number and splits into three parts
//and stores it in an array by modulo and dividing to get
//three parts untill number is 0
	
// CHANGED
	n = (long long)number;			
// CHANGED
	for (x = 0; x < 8; x++)	  
	{
		num[x] = n % 1000;		
		n = n / 1000;
	}
}
void getDecimal ()
{
//getDecimal and sees if fraction is from .99 or from .00 and
//makes it a int by multiplying by 100 and stores the decimal in frac[] untill fraction is 0
	if(fraction < 1 && fraction >= .00)	
	{
		fraction = fraction * 100;		
		f = (int)fraction;				
		for (x = 0; x < 2; x++)			
		{
                       
			frac[x] = f % 10;			
			f = f / 10;					 
		}								

	}
}
void getToWords ()
{
//getToWords takes the number and decimal was stored in the array
//and prints off the number it holds
//gets the number for each postion and stores it and repeats this untill
//the number it gets the result and prints it off
// REMOVED
//	x = sizeof num / sizeof(int);
// CHANGED
        x = 7;
	while(x > -1)									
	{
            if ( num[x] ){

		hun = num[x] / 100;						
		ten = (num[x] /10)% 10;					
		ones = (num[x] % 10);					

		if (hun > 0)							
		{
// CHANGED
			result.append(one[hun] + " "+ huns[0] + " ");	
		}
		
		if (ten == 0 && ones == 0)				 
		{
												
		}

		if (ten == 1)							
		{
			result.append(one[ten * 10 + ones] + " ");
		}
		
		if (ten > 1 && ones >= 1)				
		{
			result.append(tens[ten] + " " + one[ones] + " ");
		}

		else if (ten > 1)						
		{
			result.append(tens[ten] + " ");			
		}

		if (ones >= 1 && ten == 0)				
		{
			result.append(one[ones] + " ");			
		}
// CHANGED
                if ( x )
                 result.append(huns[x]);
           }
  	   x--;									
	}
// CHANGED
result.append("and ");
tths = frac[1] % 10;					
hths = frac[0] % 10;
	d = sizeof frac / sizeof(int);
	while (d > 1)
	{
		if (tths == 0 && hths == 0)					
		{
// CHANGED
			result.append("No ");				
		}
		else if (hths >= 1 && tths == 0)					
		{
			result.append(one[hths] + " ");				
		}
		else if (tths == 1)								
		{
			result.append(one[tths * 10 + hths] + " ");	
		}
		else if (tths > 1 && hths >= 1)					
		{
			result.append(tens[tths] + " " + one[hths] + " "); 
		}
		else if (tths > 1 && hths == 0)							
		{
			result.append(tens[tths] + " ");				
		}
		d--;										
	}
// Added
        result.append("cents");

	cout << result << "\n";	
}

int main()
{
	cout << "Ryan Cloud\nThis is The Written number project\n"; 
	//get a number
	//turn number to word form
	//display word form
	
	// ask the user to input a dollar amount
	cout << "\nEnter a Dollar amount\n";
	cin >> userInput; 
        cout << "User entered: " << userInput << endl;	
	if(userInput > 0)
	{
	fraction = modf(userInput, &number);
	// This seperates the number and the decimal into 2 variables. 
	//Number gets just the number and fraction just gets the decimal point from it.

	getNumber ();
	getDecimal (); 
	getToWords ();
	}
	else if (userInput == 0)
	{
		cout << one[0] << "\n";
	}
	else
	{
		cout << "Error\n";
	}
	return 0;
}
Thank you so much!!
Remember to do some more error checking(What is the largest number that works?) and if you have time try to remove the globals.
Pages: 12