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

The code must produce an answer that looks EXACTLY like this: Roman.java: Please

ID: 440950 • Letter: T

Question

The code must produce an answer that looks EXACTLY like this: Roman.java: Please enter an integer greater than 0 and less than 4000: 1978 MCMLXXVIII Please enter an integer greater than 0 and less than 4000: 3999 MMMCMXCIX Please enter an integer greater than 0 and less than 4000: 4000 Not a valid entry!

Explanation / Answer

I have done this in eclipse and is giving output correctly. sample output --------------- enter number less than 4000 456 Roman Equivalent is:CDLVI ---------------------------- import java.util.Scanner; public class Roman { static Scanner scan=new Scanner(System.in); public String IntegerToRoman(int input) { if (input < 1 || input > 3999) return "Invalid Roman Number Value"; String s = ""; while (input >= 1000) { s += "M"; input -= 1000; } while (input >= 900) { s += "CM"; input -= 900; } while (input >= 500) { s += "D"; input -= 500; } while (input >= 400) { s += "CD"; input -= 400; } while (input >= 100) { s += "C"; input -= 100; } while (input >= 90) { s += "XC"; input -= 90; } while (input >= 50) { s += "L"; input -= 50; } while (input >= 40) { s += "XL"; input -= 40; } while (input >= 10) { s += "X"; input -= 10; } while (input >= 9) { s += "IX"; input -= 9; } while (input >= 5) { s += "V"; input -= 5; } while (input >= 4) { s += "IV"; input -= 4; } while (input >= 1) { s += "I"; input -= 1; } return s; } public static void main(String[] args) { Roman roman=new Roman(); int num; System.out.println("enter number less than 4000"); num=Integer.parseInt(scan.nextLine()); System.out.println("Roman Equivalent is:"+roman.IntegerToRoman(num)); } }