# Roman Numerals ID Method

Hello all! So I’ve been working more on my Simpossible game, and specifically on the roman numerals ID minigame I talked about in earlier posts. So, in short, I’ve been working with the modulus operator nonstop for a couple hours… But it’s been really fun! So far, it’s coming together well. The majority of my time I spent on devising just how I would turn regular numbers into roman numerals. I’ve done it mostly by using whats called the “modulus” operator (%). You can read more on that here, but I’ll explain the basis for anyone unfamiliar with programming basics. It’s an operator (Like plus, minus or multiply) which will return the remainder of the first number divided by the second. So, 17 % 5 = 2. This operator is used most frequently in creating bounds for the rand() function, or to find whether or not a number is even.

My use of this operator has been to find whether or not a roman numeral requires an “X” or a “V”. So, for example, I can use the equation 17%10 = 7, and from there determine the appropriate numeral is XVII.

Below is some output and the unfinished method. I hope you enjoy!

```/*

Roman Numeral ID

*/

bool romanNumerals(int difficulty){

// Start of game

// Initialize roman numeral string to be appended

string number;

cout &lt;&lt; "Hey, ID this Roman Numeral for me.?" &lt;&lt; endl;

sleep(3);

// Difficulties below or equal to 1
if(difficulty &lt;= 1){

// Seed &amp; initialize rand
srand(time(0));
int randomNum = rand()% 5;

// Ensures rand cant = 0
if (randomNum == 0) randomNum += 3;

// If rand is &lt; 4, the numeral will only consist of "I"
if(randomNum &lt; 4){

// Create the roman numeral up to 3
for(int rep = 0; rep &lt; randomNum; rep++){

number += "I";
}

// Output numeral
cout &lt;&lt; number &lt;&lt; endl;

int temp;
cin &gt;&gt; temp;

if (temp == randomNum){

cout &lt;&lt; endl;
}

else {

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}

}

// If rand = 4
else {

// Outputs 4 in Roman Numerals
cout &lt;&lt; "IV" &lt;&lt; endl;

int temp;
cin &gt;&gt; temp;

if(temp == 4){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}
}

// Difficulty &gt; 1 &amp;&amp; &lt; or equal to 5
else if(difficulty &gt; 1 &amp;&amp; difficulty &lt;= 5){

// seeds and initializes rand range 5 - 20
srand(time(0));
int randomNum = rand() % 20 + 6;

// Rand = 5
if(randomNum == 9){

// Output
cout &lt;&lt; "IX" &lt;&lt; endl;

// User input
int temp;
cin &gt;&gt; temp;

if (temp == 9){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// Rand = 14
else if(randomNum == 14){

// Output
cout &lt;&lt; "XIV" &lt;&lt; endl;

// User input
int temp;
cin &gt;&gt; temp;

if (temp == 14){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// Rand = 15
// IDK WHY but this wont work rn
else if(randomNum == 15){

// Output
cout &lt;&lt; "XV" &lt;&lt; endl;

// User input
int temp;
cin &gt;&gt; temp;

if (temp == 15){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// Rand = 19
else if(randomNum == 19){

// Output
cout &lt;&lt; "IXX" &lt;&lt; endl;

// User input
int temp;
cin &gt;&gt; temp;

if (temp == 19){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// Rand = 6 - 20
else{

// If rand is directly divisible by 10
if ((randomNum % 10) == 0){

//Create a string which properly represents rand with Xs
for (int rep = 0; rep &lt; (randomNum/10); rep++){

number += "X";
}

// Output
cout &lt;&lt; number &lt;&lt; endl;

// User input
int temp;
cin &gt;&gt; temp;

if(temp == randomNum){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// If rand can be divided by 10 with a remainder less than 4
else if((randomNum % 10) &lt; 4){

//Starts numeral with a X
number += "X";

// Creates the random numeral
for(int rep = 0; rep &lt; (randomNum - 10); rep++){

number += "I";
}

// Output
cout &lt;&lt; number &lt;&lt; endl;

// Input
int temp;
cin &gt;&gt; temp;

if (temp == randomNum){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// If rand can be divided by 10 with a remaineder greater than 5
else if((randomNum % 10) &gt; 5){

// Starts numeral with a XV

number += "XV";

// Creates random numeral

for(int rep = 0; rep &lt; (randomNum - 15); rep++){

number += "I";
}

// Output
cout &lt;&lt; number &lt;&lt; endl;

// Input
int temp;
cin &gt;&gt; temp;

if(temp == randomNum){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

// If rand is not divisible by 10 at all, aka less than 10
else if(randomNum &gt; 5 &amp;&amp; randomNum &lt; 9){

// Starts numeral with a V
number += "V";

// Creates the random numeral
for(int rep = 0; rep &lt; (randomNum - 5); rep++){

number += "I";
}

// Output
cout &lt;&lt; number &lt;&lt; endl;

// Input
int temp;
cin &gt;&gt; temp;

if(temp == randomNum){

cout &lt;&lt; endl;
}

else{

lives --;
cout &lt;&lt; incorrectAnswer() &lt;&lt; " You have " &lt;&lt; lives &lt;&lt; " lives left! " &lt;&lt; endl &lt;&lt; endl;

//returns false
return false;

}
}

}
}

return true;
}
```