(c++) Write a program that converts a positive integer into the Roman number system.(c++)
Roman numbers. Write a program that converts a positive integer into the Roman number system. The Roman number system has digits
I 1 V 5 X 10 L 50 C 100 D 500 M 1,000
Numbers are formed according to the following rules. (1) Only numbers up to 3,999 are represented. (2) As in the decimal system, the thousands, hundreds, tens, and ones are expressed separately. (3) The numbers 1 to 9 are expressed as
I 1 II 2 III 3 IV 4 V 5 VI 6 VII 7 VIII 8 IX 9
As you can see, a I preceding a V or X is subtracted from the value, and you can never have more than three I’s in a row. (4) Tens and hundreds are done the same way, except that the letters X, L, C and C, D, M are used instead of I and V, X, respectively.
Your program should take an input, such as 1978, and convert it to Roman numerals, MCMLXXVIII.
code
#include <iostream>
#include <string>
using namespace std;
int main()
{
//ask user to input num to convert
//if num is less than 0
{
cout << "Your number must be greater than zero.";
return 1;
}
string roman = "";
int digit = num / 1000;
//if digit is equal to three
{
roman = "MMM";
}
else if (...)
{
roman = "MM";
}
else if (...)
{
roman = "M";
}
num = num % 1000;
digit = num / 100;
if (digit == 9)
{
roman = ...
}
else if (digit == 4)
{
roman = ...
}
else
{
if (digit >= 5)
{
roman = roman + "D";
digit = digit - 5;
}
if (digit == 3)
{
roman = ...;
}
else if (digit == 2)
{
roman = ...;
}
else if (digit == 1)
{
roman = ...;
}
}
num = num % 100;
digit = num / 10;
if (digit == 9)
{
roman = roman + "XC";
}
else if (digit == 4)
{
roman = ...;
}
else
{
if (digit >= 5)
{
roman = ...;
digit = ...;
}
if (digit == 3)
{
roman = ...;
}
else if (digit == 2)
{
roman = ...;
}
else if (digit == 1)
{
roman = ...;
}
}
digit = num % 10;
if (digit == 9)
{
roman = ...;
}
else if (digit == 4)
{
roman =...;
}
else
{
if (digit >= 5)
{
roman = ...;
digit = ...;
}
if (digit == 3)
{
roman = ...;
}
else if (digit == 2)
{
roman = ...;
}
else if (digit == 1)
{
roman = ...;
}
}
//print results
//return 0
}


![for(int i-1; i<-counter;i++)1 59 60 61 romanNumeral[index+]-D // the remainder is calculated to get the number which is Less](http://img.homeworklib.com/questions/3ff4ebe0-b109-11ea-9b82-a769e7521ac5.png?x-oss-process=image/resize,w_560)


![for(int 1(scounter;i++){ 144 145 146 147 148 149 150 1-1; romanNumeral[index++]-V //the remainder is calculated to get the n](http://img.homeworklib.com/questions/412ac9f0-b109-11ea-a167-dfac1f5c56cf.png?x-oss-process=image/resize,w_560)
![for(int i-0; i<index;i++)1 173 174 175 176 cout <<romanNumeral[i] 178 179 180 //main method to start the program execution 18](http://img.homeworklib.com/questions/41894940-b109-11ea-927f-8334f0dde74f.png?x-oss-process=image/resize,w_560)

==============================================================================================
Sample output screenshots:






(c++) Write a program that converts a positive integer into the Roman number system.(c++) Roman numbers....
Write a program in C++ that converts a number entered in Roman numerals to a positive integer. Your program should consist of a class, say, romanType. An object of type romanType should do the following: Store the number as a Roman numeral. Convert and store the number as a positive integer. Print the number as a Roman numeral or positive integer as requested by the user. The integer values of the Roman numerals are: M = 1000; D = 500;...
In C++ Write a program that converts a number entered in Roman numerals to decimal. Your program should consist of a class, say,romanType. An object of typeromanTypeshould do the following:a. Store the number as a Romannumeral.b. Convert and store the number into decimalform.c. Print the number as a Roman numeral ordecimal number as requested by the user.The decimal values of the Roman numerals are:M 1000D 500C 100L 50X 10V 5I 1d. Test your program using the followingRoman numerals: MCXIV, CCCLIX,...
Write the roman.cpp implementation file that converts a number entered in Roman numerals to a positive integer. Your program should consist of a class, say, romanType. An object of type romanType should do the following: Step a: Store the number as a Roman numeral. Step b: Convert and store the number as a positive integer. Step c: Print the number as a Roman numeral or positive integer as requested by the user. Step d: Test your program using the following...
**c++*** Write a program that coverts a number to the roman number representation. Make sure to use a single function that determines the units, tens, hundreds, and thousands digits.
Write and test a function toDecimal() that converts a roman number such as MCMLXXVII to its decimal number representation. Write a main program to test the function. Your function should have two arguments - the roman number as a string, and an error processing function. Write a helper function that will return the numeric value of each of the letters used in roman numbers. Then convert the string argument as follows look at the first two characters. If the first...
Write a Java program.
In the "modern Roman" system a number is also a sequence of M's, D's, C's, L's, X's, V's, and 1's. The symbols have to appear more or less in that order and the value of a number is obtained as before with one important exception: A symbol C, X, or I may precede a symbol of higher value, in which case the value of that symbol C, X, or I is taken to be negative. Write...
Write up a detailed solution to the problem: Design a program to convert a Roman numeral to a decimal number. The program should read a Roman numeral. You may read it as a string or one character at a time. Do the conversion and then output the decimal number. Here are the “letters” you need to know: Symbol = Value I = 1 V = 5 X = 10 L = 50 C = 100 D = 500 M =...
Write a function that converts an integer number in the range [1, 2000] into Roman Numerals. void IntToRoman(int n, char *roman); Write a main() program to test and demonstrate your function
Write a C program convert.c that converts each number in an array by the sum of that number plus 6 modulus 10. A sample input/output: Enter the length of the array: 5 Enter the elements of the array: 3 928 4 14 77 Output: 9 4 0 0 3 The program should include the following function: void convert(int *a1, int n, int *a2) The function converts every element in array a1 of length n to an output array a2. The...
Write a C program to convert a given integer to roman number.Roman numerals are represented by 7different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D 500M 1000