Roman numerals help?

So far this sort of works I guess however I'm not sure how I would get it to do the IV or VII or whatever. It'll only go either IIIIIIII......, VVVVVVVV...., XXXXXXX...., etc.

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
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int main() {
	char response = 'Y';
	string roman;
	int b;
	int x;
	int i = 0;
	cout << "Enter a number" << endl;
	while (response == 'Y') {
		cin >> x;
		if (x <= 1000 && x > 0) {
			cout << "Good" << endl;
			if (x % 1000 == 0) {
				roman += 'M';
				cout << roman;
			}
			else if (x % 500 == 0) {
				roman += 'D';
				cout << roman;
			}
			else if (x % 100 == 0) {
				b = x / 100;
				for (int i = 0; i != b; i++) {
					roman += 'C';
				}
				cout << roman << endl;
			}
			else if (x % 10 == 0) {
				b = x / 10;
				for (int i = 0; i != b; i++) {
					roman += 'X';
				}
				cout << roman << endl;
			}
			else if (x % 5 == 0) {
				b = x / 5;
				for (int i = 0; i != b; i++) {
					roman += 'V';
				}
				cout << roman << endl;
			}
			else if (x % 1 == 0) {
				b = x / 1;
				for (int i = 0; i != b; i++) {
					roman += 'I';
				}
				cout << roman << endl;
			}
		}
		else {
			cout << "Not a valid choice " << endl;
			cin.clear();
			cin.ignore(1000, '\n');
		}
		cout << "Go again Y for yes: ";
		cin >> response;
		if (response == 'Y') {
			continue;
		}
		else
			response != 'Y';
	}
	cin >> response;
	return 0;
}
Never mind guys I freaking did it! Had to modify it quite a bit but I got it :D!
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
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::string;

int main() {
	char response = 'Y';
	string roman;
	int b;
	int x;
	string die = "";
	int i = 0;
	cout << "Enter a number" << endl;
	while (response == 'Y') {
		cin >> x;
		if (x <= 1000 && x > 0) {
			cout << "Good" << endl;
			if (x == 1000) {
				roman += 'M';
			}
			else if (x >= 100) {
				b = x / 100;
				if (b == 9) {
					roman += "CM";
				}
				else if (b >= 5) {
					roman += 'D';
					for (int i = 0; i != (b - 5); i++) {
						roman += 'C';
					}
				}
				else if (b == 4) {
					roman += "CD";
				}
				else {
					for (int i = 0; i != b; i++) {
						roman += 'C';
					}
				}
				x %= 100;
			}

			if (x < 100 && x >= 10) {
				b = x / 10;
				if (b == 9) {
					roman += "XC";
				}
				else if (b >= 5) {
					roman += 'L';
					for (int i = 0; i != (b - 5); i++) {
						roman += 'X';
					}
				}
				else if (b == 4) {
					roman += "XL";
				}
				else {
					for (int i = 0; i != b; i++) {
						roman += 'X';
					}
				}
				x %= 10;
			}

			if (x < 10) {
				b = x / 1;
				if (x == 9) {
					roman += "IX";
				}
				else if (x >= 5) {
					roman += "V";
					for (int i = 0; i != (b - 5); i++) {
						roman += 'I';
					}
				}
				else if (x == 4) {
					roman += "IV";
				}
				else {
					for (int i = 0; i != b; i++) {
						roman += 'I';
					}
				}
			}
			cout << roman << endl;
		}
		else {
			cout << "Not a valid choice " << endl;
			cin.clear();
			cin.ignore(1000, '\n');
		}
		cout << "Go again Y for yes: ";
		cin >> response;
		if (response == 'Y') {
			continue;
			roman = die;
			x = 0;
			b = 0;
		}
		else
			response = response;
	}
	cin >> response;
	return 0;
}
Topic archived. No new replies allowed.