Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that converts a number entered in Roman numerals to decimal. You

ID: 3636541 • Letter: W

Question

Write a program that converts a number entered in Roman numerals to decimal. Your program should consist of a Class, like romanType. An object of type romanType should do the following:
Store the number as a Roman numeral
Convert and store the number into decimal form.
Print the number as a Roman numeral or decimal number as requested by the user.
The decimal values of the Roman numerals are
M=1000, D=500, C=100, L=50, X=10, V=5, I=1.
Test the program using the following Roman numerals:
MCXIV, CCCLIX, MDCLXVI.

Explanation / Answer

#include

<iostream> //start of program.

#include

<cmath>

using

namespace std;

class

romanType // class

{

void roman();

int convert();

void print();

void get();

int M, D, C, L, X, V, I;

char romanNumeral;

};

void

romanType::roman()

{

M = 1000;

D = 500;

C = 100;

L = 50;

X = 10;

V = 5;

I = 1;

}

int

romanType::convert()

{

if (romanNumeral = M)

{

cout <<

"1000";

}

else if(romanNumeral = D)

{

cout <<

"500";

}

else if(romanNumeral = C)

{

cout <<

"100";

}

else if(romanNumeral = L)

{

cout <<

"50";

}

else if(romanNumeral = X)

{

cout <<

"10";

}

else if(romanNumeral = V)

{

cout <<

"5";

}

else if(romanNumeral = I)

{

cout <<

"1";

}

return romanNumeral;

}

void

romanType::print(){

cout << romanNumeral << endl;

}

void

romanType::get(){

}

int

main()

{

char romanNumeral;

cout <<

"This is the Roman numeral to decimal converter Please Roman numerals to be converted: ";

cin >> romanNumeral;

system (

"pause");

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote