Question: Use the attached starter code to design and implement a Roman numeral calculator. Your program should ignore the subtractive Roman numeral notation and only use
Use the attached starter code to design and implement a Roman numeral calculator. Your program should ignore the subtractive Roman numeral notation and only use a purely additive notation in which a number was simply the sum of its digits equals IIII in this notation, not IV Each number starts with the digit of highest value and ends with the digit of smallest value. The values of the Roman digits are as follows: I V X L C D M Thus, the number MDCCCCLXXXXVI represents because really consists of: M D C C C C L X X X X V I Your class inputs two Roman numbers as the operands and an arithmetic operator and prints out the result of the operation, also as a Roman number. The arithmetic operators that your program should recognize in the input are and These should perform the operations of integer addition, subtraction, multiplication, and division. As shown in the starter code the approach is to convert the Roman numbers into integers, perform the required operation, and then convert the result back into a Roman number for printing. The following might be a sample run of the class:
Enter Operator: : Enter operand: MCCXXVI Enter operand: LXVIIII Answer MCCLXXXXV You must use the structure provided in the starter code Your code should accept both lowercase and uppercase letters for Roman numerals. MDCLXVI is the same as mdclxvi Your Roman Calculator should be tested with the following inputs note your program will fill in the answers: Operator: : Enter operand: M Enter operand: mCxV Answer Operator: : Enter operand: XX Enter operand: v Answer Operator: : Enter operand: x Enter operand: lx Answer Operator: : Enter operand: dc Enter operand: x Answer Operator: : Enter operand: mmc Enter operand: lxvii Answer Operator: : Enter operand: m Enter operand: cxi Answer Operator: : Your operand is bad try again:
Operator: : Enter operand: axi bad character Enter operand: xi Enter operand: xii bad character Enter operand: xii
COMPLETE THIS CODE!!!
import java.util.Scanner;
public class RomanCalculator
public static Scanner kbInput new ScannerSystemin;
public static String doMathchar operator, int firstNum, int secondNum
This method will perform the arithmetic
indicated by the operator
invoke convertToRoman to convert answer to Roman number,
then return answer
public static char getOperator
Modify this method so when the user enters an invalid operator the
program will complain and ask the user to enter again
System.out.printlnplease choose an operator: or ;
return kbInput.nextLinecharAt; public static int getOperands
This routine should prompt the user to enter Roman number. convertFromRoman needs to be invoked to convert the Roman number to an integer. If the input is invalid returned from convertFromRoman then complain and prompt the user again.
public static int convertFromRomanString romanNum
This method will convert Roman number to integer return when input is invalid
public static String convertToRomanint num
This method will convert integer to Roman number
public static void mainString args
TODO Autogenerated method stub
String result;
do result doMathgetOperator getOperands getOperands; System.out.printlnresult; System.out.printlndo you want to continue? yn;
while kbInputnextLinecharAty;
System.out.printlnHave a nice day!";
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
