Question

In: Computer Science

Write a java program to convert a positive integer value to a roman number. Your program...

Write a java program to convert a positive integer value to a roman number. Your program should print a description, prompt them for how many numbers they need to convert and then loop that many times. Each time the program needs to prompt for a number and output the equivalent roman numeral. If the user enters a number less than 1 then output an error message. See sample output below:

****************************************************

* Welcome to the Roman Numeral Converter!          *

* You can use this tool to convert any decimal     *

* value into a Roman Numeral. To get started       *

* please enter the how many decimal numbers you    *

* need to convert.                                 *

****************************************************

How many numbers do you have to convert? 5

Please enter the number that you would like to convert: 58

58 as a Roman Numeral is LVIII

Please enter the number that you would like to convert: 2019

2019 as a Roman Numeral is MMXIX

Please enter the number that you would like to convert: -85

Sorry, but -85 is not a positive number and cannot be converted

Please enter the number that you would like to convert: 7

7 as a Roman Numeral is VII

Please enter the number that you would like to convert: 23

23 as a Roman Numeral is XXIII

Requirements

You must have a helper class RomanHelper with the following methods. It will be up to you to determine the return type and parameters required for each:

  • description: Print the program description to the screen
  • getRoman: Converts an integer to a Roman Numeral. No output to the screen should happen here.

Also, you will need to have a driver class RomanDriver with the following methods:

  • main: Construct a Scanner object and call the runProgram method.
  • runProgram: Prompt the user how many times they would like to run the program and loop that many times calling the getNextNumber method.
  • getNextNumber: Prompt for a number to convert and output the result or an error message if the number isn’t positive.

You may add however many additional methods that you would like.

Solutions

Expert Solution

output:


Related Solutions

Write a program in C++ that converts a positive integer into the Roman number system. The...
Write a program in C++ 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...
Write a program in C++ that converts a positive integer into the Roman number system. The...
Write a program in C++ 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...
Write a Java program to convert decimal (integer) numbers into their octal number (integer) equivalents. The...
Write a Java program to convert decimal (integer) numbers into their octal number (integer) equivalents. The input to the program will be a single non-negative integer number. If the number is less than or equal to 2097151, convert the number to its octal equivalent. If the number is larger than 2097151, output the phrase “UNABLE TO CONVERT” and quit the program. The output of your program will always be a 7-digit octal number with no spaces between any of the...
Write a Java program to convert decimal (integer) numbers into their octal number (integer) equivalents. The...
Write a Java program to convert decimal (integer) numbers into their octal number (integer) equivalents. The input to the program will be a single non-negative integer number. If the number is less than or equal to 2097151, convert the number to its octal equivalent. If the number is larger than 2097151, output the phrase “UNABLE TO CONVERT” and quit the program. The output of your program will always be a 7-digit octal number with no spaces between any of the...
java Write a recursive program to reverse a positive integer. . Your method should take a...
java Write a recursive program to reverse a positive integer. . Your method should take a non negative integer as a parameter and return the reverse of the number as an integer. e.g. if you pass 12345, your method should return 54321.
6.28 LAB: Convert to binary - functions Write a program that takes in a positive integer...
6.28 LAB: Convert to binary - functions Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is: As long as x is greater than 0 Output x % 2 (remainder is either 0 or 1) x = x / 2 Note: The above algorithm outputs the 0's and 1's in reverse order. You will need to write a second...
ks) Write a program that prompts a person to enter a positive integer value. If the...
ks) Write a program that prompts a person to enter a positive integer value. If the value cannot be converted into an integer or if the value is less than 1, keep prompting the user to enter a value until they enter a valid integer value. Determine if the value is odd or even and display the result on the screen. Pause the screen until the user presses a key to continue.(c programming begineers method
Write a C++ program that accepts a positive integer number from the keyboard . The purpose...
Write a C++ program that accepts a positive integer number from the keyboard . The purpose of the program is to find and the display all the square pair numbers between 1 and that number. The user should be able to repeat the process until he/she enters n or N in order to terminate the process and the program. Square numbers are certain pairs of numbers when added together gives a square number and when subtracted also gives a square...
Write a program in C or in Java, that takes an integer value N from the...
Write a program in C or in Java, that takes an integer value N from the command line, generates N random points in the unit square, and computes the distance separating the closest pair of points. A unit square is a square with sides of length 1, at points (0, 0), (0, 1), (1, 0), and (1, 1). If you wish to avoid the command-line processing, you can just assume you will generate a fixed number of points, say between...
JAVA Language: Write a program that prompts the user to enter a positive integer n (0...
JAVA Language: Write a program that prompts the user to enter a positive integer n (0 up to 232 -1). You must write a function that takes as input n and returns a string s representing the number n in binary. For this assignment, you must use the method of successive division by 2 to convert the number to binary. Your main program must print out s. Example: If the user enters the number 66, your program must print out...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT