Please help with short form roman numerals c++

i have long form packed down farely well. i just need the last 2 "nothing" and "imverytired" strings to be short form roman numerals. ie (long form: 524=DXXIIII) (short form:524=DXXIV)
My program is supposed to run 4 things. Toupper long roman numeral. Tolower long roman numeral. Toupper short roman numeral. Tolower short roman numeral.
Yes I know I did the upper and lower wrong. But frankly I've been working on this for 13 hours today. And I'm sick of it. I can't figure out how to get theshort roman numeral..
heres my code.. i really need help.
Any advice would be much appreciated.

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

// roman_numeral.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>
#include <algorithm>
#include<math.h>
#include <ctype.h>
#include <cctype>
#include <functional>
using namespace std;
int main()




{

int x=0,i=0,n=0,w=0,e=0,q=0, start=0;
string nothing = "";
string imverytired = "";
string nothealthytired = "mdclxvi";
string roman = "MDCLXVI";
string p = "What would you like to start with? <1-5000>";
string o = "that number is not in the range of 1-5000.";

cout << "what would you like to start with? <1-5000>" ;
cin >> start;

while(start<1||start>5000)
{
cout<<"that number is not in the range of 1-5000.";
cout<< "what would you like to start with? <1-5000>";
cin >> start;
}
//..............................UPPER CASE................................
for(i=start;i<=start+20;i++)
{
x=i;
n=x/1000;
nothing.append(n,roman[0]);
x=x%1000;

n=x/500;
nothing.append(n,roman[1]);
x=x%500;

n=x/100;
nothing.append(n,roman[2]);
x=x%100;

n=x/50;
nothing.append(n,roman[3]);
x=x%50;

n=x/10;
nothing.append(n,roman[4]);
x=x%10;

n=x/5;
nothing.append(n,roman[5]);
x=x%5;

n=x/1;
nothing.append(n,roman[6]);
x=x%1;
//..............................................................................	

//..................................lower case...............................	

w=i;
q=w/1000;
imverytired.append(q,nothealthytired[0]);
w=w%1000;

q=w/500;
imverytired.append(q,nothealthytired[1]);
w=w%500;

q=w/100;
imverytired.append(q,nothealthytired[2]);
w=w%100;

q=w/50;
imverytired.append(q,nothealthytired[3]);
w=w%50;

q=w/10;
imverytired.append(q,nothealthytired[4]);
w=w%10;

q=w/5;
imverytired.append(q,nothealthytired[5]);
w=w%5;

q=w/1;
imverytired.append(q,nothealthytired[6]);
w=w%1;
//..............................................................................
cout<<i<<"="<<nothing<<"="<<imverytired<<"="<<nothing<<"="<<imverytired<<end;
nothing="";
imverytired="";
}








system("pause");
return 0;
}
U could start by replacing lines 94 to 100 with this...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if(w%5 == 4) //the exception case
{      //do a special append
	imverytired.append(1,nothealthytired[6]); 
	imverytired.append(1,nothealthytired[5]);
}
else
{
   q=w/5;
   imverytired.append(q,nothealthytired[5]);
   w=w%5;

   q=w/1;
   imverytired.append(q,nothealthytired[6]);
   w=w%1;
}


Make something similar for the cases 9 and 49(?) etc
Last edited on
Topic archived. No new replies allowed.