Question: Write a java program to convert an integer to roman. We have to solve it without loops, which is why I'm trying to figure out

Write a java program to convert an integer to roman. We have to solve it without loops, which is why I'm trying to figure out how to use replace.

I have the following code that I struggle to get working. Please don't send an answer with loops, I already know how to solve it that way.

Fingers crossed, I hope someone can help me out. :)

Write a java program to convert an integer to roman. We have

2 public class RomanNumerals 4 public String getRomanNumber(int number) I 6 return joinC"", nCopies(number, "I")) .replaceC"IIII", "IV") .replaceC"VV", "X") .replaceC"VIV", "IX") .replaceC"XXXXX", "L") .replaceC"XXXX", "XL") replaceC"LL", "C") .replaceC"LXL", "XC") .replaceC"CCCCC", "D") .replaceC"CCCC", "CD" . replace("DD", "M") .replace"DCD", "CM") 7 10 12 13 14 15 16 17 18 19

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!