Translation code, errors!

So, this code was put together from various sources in a team assignment and my current job is to make the code work. Unfortunately, I receive some errors when trying to run the code. Any idea how to solve them?

ERRORS:
Error 1 error LNK2019: unresolved external symbol "void __cdecl toRom(void)" (?toRom@@YAXXZ) referenced in function _main C:\Users\Damir\documents\visual studio 2013\Projects\mcgivney_extra_credit\mcgivney_extra_credit\Source.obj mcgivney_extra_credit
Error 2 error LNK1120: 1 unresolved externals C:\Users\Damir\documents\visual studio 2013\Projects\mcgivney_extra_credit\Debug\mcgivney_extra_credit.exe mcgivney_extra_credit

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
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
 #include <iostream>
#include <string>

using namespace std;

//Function Header
void toarabConv(void);
void toRom(void);


int main(void)
{
	int loop = 1;
	char type;
	while (loop == 1)
	{
		cout << "This program is designed to convert Roman Numeral to Arabic numeral, or vice-versa.\n\n";
		cout << "Do you want to convert to Roman or to Arabic? R for Roman, A for Arabic (Q to quit): ";
		cin >> type;
		type = toupper(type);
		if (type == 'Q') //quit option
			{
				loop = 0;
				return loop;
			}
		else
			{
				break;
			}
		while ((type != 'R') || (type != 'A'))
		{
			cout << "\nUser Error: If you want to convert to Roman, enter an R. If you want to convert to Arabic, enter an A." << endl; //Not witty enough to make mean remarks!
			cout << "Do you want to convert to Roman or to Arabic? R for Roman, A for Arabic (Q to quit): ";
			cin >> type;
			type = toupper(type);
			if (type == 'Q')
				{
					loop = 0;
					return loop;
				}
			else
				{
					break;
				}//end if/else
		}//end while for type
		if (type == 'A')
		{
			toarabConv();
			break;
		}
		else
		{
			toRom(); //call function roman conversion
			break;
		}//end else

	}//end while for variable loop
}//end main

//Roman to Arabic
void toarabConv(void)
{
		char s[10];
		int sum = 0, i = 0;
		cout << "Enter a Roman numeral: "; //decide on a limit? Or an equation that should work it all out?
		cin >> s;
		while (s[i] != '\0')
		{
			switch (s[i])
			{
			case 'm':sum += 1000;
				break;
			case 'd':if (s[i - 1] == 'c')
				sum += 400;
					 else if (s[i - 1] == 'l')
						 sum += 450;
					 else
						 sum += 500;
					 break;
			case 'c':if (s[i + 1] != 'd')
			{
						 if (s[i - 1] == 'l')
							 sum += 50;
						 else
							 sum += 100;
			}
					 break;
			case 'l':if (s[i + 1] != 'c')
				sum += 50;
				break;
			case 'x':if (s[i - 1] == 'i')
				sum += 9;
					 else
						 sum += 10;
				break;
			case 'v':if (s[i - 1] == 'i')
				sum += 4;
					 else
						 sum += 5;
				break;
			case 'i':if (s[i + 1] != 'x' || s[i + 1] != 'v')
				sum += 1;
				break;
			default:cout << "Invalid Roman numeral arises :";
			}
			i++;
		}
		cout << "The Roman numeral " << s << " translates to Arabic number " << sum << "." << endl;
		return;
}//end R2A function

	//Arabic to Roman
void torom(void)
	{
	int num = 0;
	cout << "Enter an Arabic number between 1 and 5000: "; //decide on a limit?
	cin >> num;
	while ((num > 5000) || (num <= 0))
	{
		cout << "User Error: You can only use a number between 1 and 5000." << endl;
		cin >> num;
	}
	
	int intnum, m, d, c, l, x, v, i, n;
	{
		int num = 1;
		intnum = (int)num;
		if (intnum >= 1000)
		{
			m = intnum / 1000;
			n = 0;
			{
				for (n; n < m; n++)
					cout << "M";
			}
			intnum = intnum % 1000;
		}
		if (intnum >= 900)
		{
			cout << "CM";
			intnum = intnum % 900;
		}
		else if (intnum >= 500)
		{
			{
				d = intnum / 500;
				n = 0;
				for (n; n < d; n++)
					cout << "D";
			}
			intnum = intnum % 500;
		}
		if (intnum >= 400)
		{
			cout << "CD";
			intnum = intnum % 400;
		}
		else if (intnum >= 100)
		{
			{
				c = intnum / 100;
				n = 0;
				for (n; n < c; n++)
					cout << "C";
			}
			intnum = intnum % 100;
		}
		if (intnum >= 90)
		{
			cout << "XC";
			intnum = intnum % 90;
		}
		else if (intnum >= 50)
		{
			{
				l = intnum / 50;
				n = 0;
				for (n; n < l; n++)
					cout << "L";
			}
			intnum = intnum % 50;
		}
		if (intnum >= 40)
		{
			cout << "XL";
			intnum = intnum % 40;
		}
		else if (intnum >= 10)
		{
			{
				x = intnum / 10;
				n = 0;
				for (n; n < x; n++)
					cout << "X";
			}
			intnum = intnum % 10;
		}
		if (intnum >= 9)
		{
			cout << "IX";
			intnum = intnum % 9;
		}
		else if (intnum >= 5)
		{
			{
				v = intnum / 5;
				n = 0;
				for (n; n < v; n++)
					cout << "V";
			}
			intnum = intnum % 5;
		}
		if (intnum >= 4)
		{
			cout << "IV";
			intnum = intnum % 4;
		}
		else if (intnum >= 1)
		{
			i = intnum;
			n = 0;
			for (n; n < i; n++)
				cout << "I";
		}
	}

	cout << endl;
	cout << "The Arabic number " << num << " translates to Roman numeral " << intnum << "." << endl;
	return;
}



Compare:
Line 8 = toRom
Line 113 = torom
C++ is case sensitive.
Thanks for that. Definitely overlooked that!

The only problem I have now is that it wont read the call to functions.
Note: I changed the code a little bit.
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
#include <iostream>
#include <string>

using namespace std;

//Function Header
void toarabConv();
void toRom();


int main()
{
	int loop = 1;
	char type;
	while (loop == 1)
	{
		cout << "This program is designed to convert Roman Numeral to Arabic numeral, or vice-versa.\n\n";
		cout << "Do you want to convert to Roman or to Arabic? R for Roman, A for Arabic (Q to quit): ";
		cin >> type;
		type = tolower(type);
		if (type == 'q') //quit option
		{
			loop = 0;
			return loop;
		}
		else
		{
			break;
		}
		while ((type != 'r') || (type != 'a'))
		{
			cout << "\nUser Error: If you want to convert to Roman, enter an R. If you want to convert to Arabic, enter an A." << endl; //Not witty enough to make mean remarks!
			cout << "Do you want to convert to Roman or to Arabic? R for Roman, A for Arabic (Q to quit): ";
			cin >> type;
			type = tolower(type);
			if (type == 'q')
			{
				loop = 0;
				return loop;
			}
			else
			{

				break;
			}//end if/else
		}//end while for type
		if (type == 'a')
		{
			toarabConv();
			break;
		}
		else
		{
			toRom();
			break;
		}//end else

	}//end while for variable loop
}//end main

//Roman to Arabic
void toarabConv()
{
	char num[5];
	int sum = 0, i = 0;
	cout << "Enter a Roman numeral: "; //decide on a limit? Or an equation that should work it all out?
	cin >> num;

	for (int i = 0; i < 5; i++)//Sum
	{
		num[i] = tolower(num[i]);
		switch (num[i])
		{
		case 'm': sum += 1000; break;
		case 'd': sum += 500; break;
		case 'c': sum += 100; break;
		case 'l': sum += 50; break;
		case 'x': sum += 10; break;
		case 'v': sum += 5; break;
		case 'i': sum += 1; break;
		default:
			cout << "Error: Invalid characters encountered." << endl;
			int error = 1;
			sum = 0;
			while (error != 0)
			{
				cout << "Enter a roman numeral:\t";
				cin >> num;
				for (int i = 0; i < 5; i++)//Sum
				{
					num[i] = tolower(num[i]);
					switch (num[i])
					{
					case 'm': sum += 1000; break;
					case 'd': sum += 500; break;
					case 'c': sum += 100; break;
					case 'l': sum += 50; break;
					case 'x': sum += 10; break;
					case 'v': sum += 5; break;
					case 'i': sum += 1; break;
					default:
						cout << "Error: Invalid characters encountered." << endl;
						int error = 1;
						sum = 0;
					}//end switch
				}//end for
			}//end while
		}//end for
	}//end while
	cout << endl;
	cout << "The Roman numeral, " << num << " translates to Arabic number, " << sum << "." << endl;
	return;
}//end R2A function

//Arabic to Roman
void toRom()
{
		int num = 0, onum = 0;
		cout << "Enter an Arabic number between 1 and 5000: "; //decide on a limit?
		cin >> onum;
		while ((num > 5000) || (num <= 0))
		{
			cout << "User Error: You can only use a number between 1 and 5000." << endl;
			cin >> num;
		}
		num = onum;

		int m, d, c, l, x, v, i, n;
		{
			int num = 0;
			if (num >= 1000)
			{
				m = num / 1000;
				n = 0;
				{
					for (n; n < m; n++)
						cout << "M";
				}
				num = num % 1000;
			}
			if (num >= 900)
			{
				cout << "CM";
				num = num % 900;
			}
			else if (num >= 500)
			{
				{
					d = num / 500;
					n = 0;
					for (n; n < d; n++)
						cout << "D";
				}
				num = num % 500;
			}
			if (num >= 400)
			{
				cout << "CD";
				num = num % 400;
			}
			else if (num >= 100)
			{
				{
					c = num / 100;
					n = 0;
					for (n; n < c; n++)
						cout << "C";
				}
				num = num % 100;
			}
			if (num >= 90)
			{
				cout << "XC";
				num = num % 90;
			}
			else if (num >= 50)
			{
				{
					l = num / 50;
					n = 0;
					for (n; n < l; n++)
						cout << "L";
				}
				num = num % 50;
			}
			if (num >= 40)
			{
				cout << "XL";
				num = num % 40;
			}
			else if (num >= 10)
			{
				{
					x = num / 10;
					n = 0;
					for (n; n < x; n++)
						cout << "X";
				}
				num = num % 10;
			}
			if (num >= 9)
			{
				cout << "IX";
				num = num % 9;
			}
			else if (num >= 5)
			{
				{
					v = num / 5;
					n = 0;
					for (n; n < v; n++)
						cout << "V";
				}
				num = num % 5;
			}
			if (num >= 4)
			{
				cout << "IV";
				num = num % 4;
			}
			else if (num >= 1)
			{
				i = num;
				n = 0;
				for (n; n < i; n++)
					cout << "I";
			}
		}

		cout << endl;
		cout << "The Arabic number " << onum << " translates to Roman numeral " << num << "." << endl;
		return;
	}

The only problem I have now is that it wont read the call to functions.
hmmm

This makes no sense:
1
2
3
4
5
6
7
8
9
		if (type == 'q') //quit option
		{
			loop = 0;
			return loop;
		}
		else
		{
			break;
		}
The loop ends no matter what you type
Yes, it tests first for the quit option, and is followed by the test for 'a' or 'r'. If it is a 'q' for quit, it returns the loop variable.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
	while ((type != 'r') || (type != 'a'))
		{
			cout << "\nUser Error: If you want to convert to Roman, enter an R. If you want to convert to Arabic, enter an A." << endl; //Not witty enough to make mean remarks!
			cout << "Do you want to convert to Roman or to Arabic? R for Roman, A for Arabic (Q to quit): ";
			cin >> type;
			type = tolower(type);
			if (type == 'q')
			{
				loop = 0;
				return loop;
			}
			else
			{
				break;
			}//end if/else
		}//end while for type 
Last edited on
Still: it makes no sense. The loop ends no matter what you type. Just remove the else branch on line 26 and 41.

You don't need to set loop to 0. Your program ends on return, no one cares for the variabe loop anymore
Topic archived. No new replies allowed.