Question: In this program, you are to create a Roman Numeral class to handle roman numeral operations. How to convert a Roman Numeral to a standard

In this program, you are to create a Roman Numeral class to handle roman numeral operations.

How to convert a Roman Numeral to a standard base ten number : : Locate the first individual roman number in the roman number string. Sum up the numeric value of the individual number. Chop off the individual roman numeral from the string and continue the process if the string has more numbers left.

How to convert a standard base ten number to a Roman Numeral : : Find the first Roman numeral less than the number. Add the roman numeral to a string. Subtract the value of the Roman Numeral from the number. Repeat this until the original number is less than the current Roman Numeral. Move to the next Roman Numeral in the list and repeat the process.

starter code

public class RomanNumeral { private int number; private String roman;

private final static int[] NUMBERS= {1000,900,500,400,100,90, 50,40,10,9,5,4,1};

private final static String[] LETTERS = {"M","CM","D","CD","C","XC", "L","XL","X","IX","V","IV","I"};

/** * Constructor to create an instance of the RomanNumeral class * * @param str String representing the Roman Numeral */ public RomanNumeral(String str) { }

/** * Constructor to create an instance of the RomanNumeral class * * @param orig Base 10 representation to be converted to a Roman Numeral */ public RomanNumeral(int orig) { }

/** * Set the base 10 value of the Roman Numeral * * @param num Base 10 value. */ public void setNumber(int num) { }

/** * Set the Roman numeral * * @param rom Roman numeral represented as a String. */ public void setRoman(String rom) { }

/** * Get the base 10 value of the Roman numeral * * @return The base 10 value of the Roman numeral. */ public int getNumber() { return number; }

/** * Get Roman numeral represented as a String * * @return Roman numeral. */ public String toString() { return roman; } }

Sample Data :

10

100

1000

2500

1500

23

38

49

LXXVII

XLIX

XX

XXXVIII

Sample Output :

10 is X

100 is C

1000 is M

2500 is MMD

1500 is MD

23 is XXIII

38 is XXXVIII

49 is XLIX

LXXVII is 77

XLIX is 49

XX is 20

XXXVIII is 38

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!