ok I am baffle maybe I am in the wrong class but I have
#include <string>
#include <iostream>
using namespace std;
std string numerals = "1 5 10 50 100 500 1000";
int main()
{
int roman_numeral = 0;
char arabic_numeral;
cout << "Enter the Number : ";
while(cin.get(roman_Numeral))
{
if(arabic_Numeral == '1000')
roman_Numeral = roman_Numeral + M;
else if(arabic_Numeral == '500')
{
arabic_Numeral = cin.peek();
if(numerals.find(arabic_Numeral, 5) != std::string::npos)
{
roman_Numeral = roman_Numeral - D;
continue;
}
else
{
roman_Numeral = roman_Numeral + D;
continue;
}
}
else if(arabic_Numeral == '100')
{
arabic_Numeral = cin.peek();
if(numerals.find(arabic_Numeral, 4) != std::string::npos)
{
roman_Numeral = roman_Numeral - C;
continue;
}
else
{
roman_Numeral = roman_Numeral + C;
continue;
}
}
else if(arabic_numeral == '50')
{
roman_Numeral = cin.peek();
if(numerals.find(roman_Numeral, 3) != std::string::npos)
{
arabic_Numeral = arabic_Numeral - L;
continue;
}
else
{
arabic_Numeral = arabic_Numeral + L;
continue;
}
}
else if(arabic_Numeral == '10')
{
roman_Numeral = cin.peek();
if(numerals.find(arabic_Numeral, 2) != std::string::npos)
{
roman_Numeral = roman_Numeral - X;
continue;
}
else
{
roman_Numeral = roman_Numeral + X;
continue;
}
}
else if(arabic_Numeral == '5')
{
roman_Numeral = cin.peek();
if(numerals.find(arabic_Numeral, 1) != std::string::npos)
{
roman_Numeral = roman_Numeral - V;
continue;
}
else
{
roman_Numeral = roman_Numeral + V;
continue;
}
}
else if(arabic_Numeral == '1')
{
arabic_Numeral = cin.peek();
if(numerals.find(arabic_Numeral) != std::string::npos)
{
roman_Numeral = roman_Numeral - I;
continue;
}
else
{
roman_Numeral = roman_Numeral + I;
continue;
}
}
else
break;
}
cout << roman_Numeral << endl;
return 0;
}
so far but it is not working I definitly need help with this if anyone has any tips or can maybe spot the error I dont know if the math is wrong on it or maybe you cant do the algorithms like you can with arabic numbers
#include <string>
#include <iostream>
using namespace std;
std string numerals = "1 5 10 50 100 500 1000";
int main()
{
int roman_numeral = 0;
char arabic_numeral;
cout << "Enter the Number : ";
while(cin.get(roman_Numeral))
{
if(arabic_Numeral == '1000')
roman_Numeral = roman_Numeral + M;
else if(arabic_Numeral == '500')
{
arabic_Numeral = cin.peek();
if(numerals.find(arabic_Numeral, 5) != std::string::npos)
{
roman_Numeral = roman_Numeral - D;
continue;
}
else
{
roman_Numeral = roman_Numeral + D;
continue;
}
}
else if(arabic_Numeral == '100')
{
arabic_Numeral = cin.peek();
if(numerals.find(arabic_Numeral, 4) != std::string::npos)
{
roman_Numeral = roman_Numeral - C;
continue;
}
else
{
roman_Numeral = roman_Numeral + C;
continue;
}
}
else if(arabic_numeral == '50')
{
roman_Numeral = cin.peek();
if(numerals.find(roman_Numeral, 3) != std::string::npos)
{
arabic_Numeral = arabic_Numeral - L;
continue;
}
else
{
arabic_Numeral = arabic_Numeral + L;
continue;
}
}
else if(arabic_Numeral == '10')
{
roman_Numeral = cin.peek();
if(numerals.find(arabic_Numeral, 2) != std::string::npos)
{
roman_Numeral = roman_Numeral - X;
continue;
}
else
{
roman_Numeral = roman_Numeral + X;
continue;
}
}
else if(arabic_Numeral == '5')
{
roman_Numeral = cin.peek();
if(numerals.find(arabic_Numeral, 1) != std::string::npos)
{
roman_Numeral = roman_Numeral - V;
continue;
}
else
{
roman_Numeral = roman_Numeral + V;
continue;
}
}
else if(arabic_Numeral == '1')
{
arabic_Numeral = cin.peek();
if(numerals.find(arabic_Numeral) != std::string::npos)
{
roman_Numeral = roman_Numeral - I;
continue;
}
else
{
roman_Numeral = roman_Numeral + I;
continue;
}
}
else
break;
}
cout << roman_Numeral << endl;
return 0;
}
so far but it is not working I definitly need help with this if anyone has any tips or can maybe spot the error I dont know if the math is wrong on it or maybe you cant do the algorithms like you can with arabic numbers