These should all be const, since you don't want to ever modify them. Also, it will help you to make an array of these so that you have similar numerals in an array together.
the professor wont let us use arrays for this program though
Code:
i=1;
n=input%10;
if (n == 4 || n == 9)
{
// handle 4 and 9 separately
}
else
{
// handle 5 ..and start 6,7,8
while(i<=n)
{
roman=roman+rome1;
i=i+1;
}
}
Instead of using rome1, put this in a loop. For each digit, print the corresponding roman numeral value. This is where having the above mentioned array helps.
how can i get the same results without using arrays?
Code:
//trying to find the thousands spot
//the input cannot exceed 4000 and cannot be 4000 also input cannot be lower
//1000
else if( (input<4000 && input != 4000) && !(input < 1000) )
{
input=input/1000%10;//isolate the digit in the thousands place
//cout<<input;
}
//trying to find the hundreds spot
//the input cannot exceed 1000 and be less than 100
else if(input<1000 && input>=100)
{
input=input%1000/100;
//cout<<input;
}
else if(input<100 && input>=10)
{
input=input%100/10;
//cout<<input;
}
else if(input<10 && input>0 && input>=1)
{
input=input%10;
//cout<<input;
}
else
{
cout<<"nada";
}
You don't need all this. Handle each decimal place in a single loop.