package project08 Project08a java A program that converts decimal numbers to Roman numerals Used to practice breaking code up into methods author import java util Scanner public class Project08 public static void main String args Scanner Yi new Scanner System in String RomanNumeral int validnumber while true validnumber promptUserForNumber Yi if validnumber 0 break RomanNumeral convertNumberToNumeral validnumber System out println RomanNumeral Yi close private static int promptUserForNumber Scanner inScanner boolean run true int number 0 while run System out println Input a number between 1 and 3999 or 0 to quit number inScanner nextInt if number 3999 number 1 number 0 System out println You re not very good at listening to directions are you else run false return number private static String convertNumberToNumeral int number char one I char five V char ten X char fifty L char onehundred C char fivehundred D char onethousand M String str str convertDigitToNumeral number one five ten number 10 str convertDigitToNumeral number ten fifty onehundred str number 10 str convertDigitToNumeral number onehundred fivehundred onethousand str number 10 while number 0 str onethousand str number return str private static String convertDigitToNumeral int digit char one char five char ten String str if digit 9 digit 0 return Invalid Digit if digit 9 str ten digit 10 else if digit 4 str five digit 5 while digit 0 str one digit while digit 0 str one str digit return str
View Full Document