#include <iostream.h>
#include <iomanip.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include <string.h>
void romanrecorder_1();
void romanrecorder_2();
void romanprinter_1();
void romanprinter_2();
void operation();
void roman_translator();
void exitprogram();
char opsign;
char I,V,X,L,C,D,M;
char letter_1;
char letter_2;
int a;
int Ia;
int b;
int Vb;
int c;
int Xc;
int d;
int Ld;
int e;
int Ce;
int f;
int Df;
int g;
int Mg;
int first_number;
int second_number;
int total;
int romantotal;
char roman_array[100];
int main()
{
a=0;
b=0;
c=0;
d=0;
e=0;
f=0;
g=0;
clrscr();
cout<<"Enter the first Roman Numeral followed by a dot(.): ";
romanrecorder_1();
return 0;
}
void romanrecorder_1()
{
cin>>letter_1;
if (letter_1=='I')
{
a++;
}
else if (letter_1=='V')
{
b++;
}
else if (letter_1=='X')
{
c++;
}
else if (letter_1=='L')
{
d++;
}
else if (letter_1=='C')
{
e++;
}
else if (letter_1=='D')
{
f++;
}
else if (letter_1=='M'){
g++;
}
romanprinter_1();
}
void romanprinter_1()
{
Ia=1*a;
Vb=5*b;
Xc=10*c;
Ld=50*d;
Ce=100*e;
Df=500*f;
Mg=1000*g;
first_number=Ia+Vb+Xc+Ld+Ce+Df+Mg;
cout<<endl<<"The first Roman Numeral is "<<first_number;
cout<<endl;
a=0;
b=0;
c=0;
d=0;
e=0;
f=0;
g=0;
cout<<endl<<"Enter the second Roman Numeral followed by a dot(.):";
romanrecorder_2();
}
void romanrecorder_2()
{ cin>>letter_2;
if (letter_2=='I')
{
a++;
}
else if (letter_2=='V')
{
b++;
}
else if (letter_2=='X')
{
c++;
}
else if (letter_2=='L')
{
d++;
}
else if (letter_2=='C')
{
e++;
}
else if (letter_2=='D')
{
f++;
}
else if (letter_2=='M'){
g++;
}
romanprinter_2();
}
void romanprinter_2()
{
Ia=1*a;
Vb=5*b;
Xc=10*c;
Ld=50*d;
Ce=100*e;
Df=500*f;
Mg=1000*g;
second_number=Ia+Vb+Xc+Ld+Ce+Df+Mg;
cout<<endl<<"The second number is "<<second_number;
a=0;
b=0;
c=0;
d=0;
e=0;
f=0;
g=0;
cout<<endl<<endl;
cout<<"Enter the desired arithmetic operation: ";
operation();
}
void operation()
{
cin >> opsign;
if (opsign=='+')
{
total=first_number+second_number;
cout<<endl<<"The sum of "<<first_number<<" and "<<second_number<<" is "<<total;
}
else if (opsign=='-')
{
if (first_number>second_number)
{
total=first_number-second_number;
}
else if (second_number>first_number)
{
total=second_number-first_number;
}
cout<<endl<<"The difference of "<<first_number<<" and "<<second_number<<" is "<<total;
}
else if (opsign=='*')
{
total=first_number*second_number;
cout<<endl<<"The multiplication of "<<first_number<<" and "<<second_number<<" is "<<total;
}
else if (opsign=='/')
{
total=first_number/second_number;
cout<<endl<<"The division of "<<first_number<<" and "<<second_number<<" is "<<total;
}
cout<<endl<<endl;
cout<<"The roman numeral value of "<<total<<" is ";
roman_translator();
}
void roman_translator()
{
romantotal=total+1;
if (romantotal>0)
{
while (romantotal>total)
{
if ( total>=1000)
{
total=total-1000;
cout<<"M";
romantotal=total+1;
}
else if (total>=500)
{
total=total-500;
cout<<"D";
romantotal=total+1;
}
else if (total>=100)
{
total=total-100;
cout<<"C";
romantotal=total+1;
}
else if (total>=50)
{
total=total-50;
cout<<"L";
romantotal=total+1;
}
else if (total>=10)
{
total=total-10;
cout<<"X";
romantotal=total+1;
}
else if (total>=5)
{
total=total-5;
cout<<"V";
romantotal=total+1;
}
else if (total>=1)
{
total=total-1;
cout<<"I";
romantotal=total+1;
}
else
{
romantotal--;
}
}
}
getch();
}