How do I make a C++ program that converts Roman Numerals to standard Arabic numbers? Can anyone give me an example of the program?
How to make a c++ program that converts roman numerals to standard arabic?
lol i did this for school in java here it is, also i just got my ap scores and i got a 5 in comp sci yay
public class roman
{
public static void main(String[]args)
{
int num=1998;
int a=1000;
int i;
int j;
String rom="M";
for(i=1;i%26lt;=13;i++)
{
j=num/a;
while(j!=0)
{
System.out.print(rom);
num=num-a;
j--;
}
if(i==1)
{
a=900;
rom="CM";
}
if(i==2)
{
a=500;
rom="D";
}
if(i==3)
{
a=400;
rom="CD";
}
if(i==4)
{
a=100;
rom="C";
}
if(i==5)
{
a=90;
rom="XC";
}
if(i==6)
{
a=50;
rom="L";
}
if(i==7)
{
a=40;
rom="XL";
}
if(i==8)
{
a=10;
rom="X";
}
if(i==9)
{
a=9;
rom="IX";
}
if(i==10)
{
a=5;
rom="V";
}
if(i==11)
{
a=4;
rom="IV";
}
if(i==12)
{
a=1;
rom="I";
}
}
}
}
Reply:It is not that easy you need to map roman numerals to arabic glyphs(small images which represent arabic character). May be you can contact a internationalization expert at websites like http://getafreelnacer.com/
Reply:A multiple if ..... then statement group. ~
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment