Java problem need help where it says fill in the blank most
Java problem, need help where it says fill in the blank. most of the problem is done and an example out put is given.
Roman Calculator Problem
Create a package named roman_calculator for this program.
Your Roman Calculator should be tested with the following inputs (note your program will fill in the answers):
Solution
package roman_calculator;
import java.util.Scanner;
public class RomanCalculator
 {
     Scanner scan = new Scanner(System.in);
     boolean doCalculation()
     {
       char operand;
        operator =getOperator();
if (operator == \'q\')
return false;
int operand1 =getOperand(1),operand2 = getOperand(2);
int answer =doArithmetic(operand1, operand2, operator);
String sAnswer =convert_to_Roman(answer);
System.out.println(\"Answer = \" +answer);
return true;
}
char getOperator()
{
System.out.println(\"Enteroperation: + - * / q (q for QUIT): \");
String input = scan.next();
System.out.println(\"input=\"+input);
char c = input.charAt(0);
return c;
}
int getOperand(int which)
{
System.out.println(\"Enter operand \" + which + \":\");
String op1 = scan.next();
return convert_from_Roman(op1);
}
String convert_to_Roman(int option)
{
{
String roman= \" \";
while (option> 0 || option < 4000)
switch (option)
{
case 1000:
roman += \'M\';
break;
case 500:
roman += \'D\';
break;
case 100:
roman += \'C\';
break;
case 50:
roman += \'L\';
break;
case 10:
roman += \'X\';
break;
case 5:
roman += \'V\';
break;
case 1:
roman += \'I\';
break;
}
return roman;
}
}
int convert_from_Roman(String value)
{
String s =value.toUpperCase();
s = s.trim();
int len = s.length();
int total = 0;
for (int i = len-1; i >= 0;i--)
{
char c =value.charAt(i);
c=Character.toUpperCase(c);
switch(c)
{
case \'M\':
total += 1000;
break;
case \'D\':
total += 500;
break;
case \'C\':
total += 100;
break;
case \'L\':
total += 50;
break;
case \'X\':
total += 10;
break;
case \'V\':
total += 5;
break;
case \'I\':
total += 1;
break;
}
}
return total;
}
int doArithmetic(int operand1, int operand2, char operator)
{
switch (operator)
{
case \'+\':
return operand1 + operand2;
case \'-\':
return operand1 - operand2;
case \'*\':
return operand1 * operand2;
case \'/\':
return operand1 / operand2;
}
return operator;
}
public static void main(String[] args)
{
RomanCalculator rc = new RomanCalculator();
while (rc.doCalculation())
{
System.out.println();
}
System.out.println(\"Finished Roman Computations\");
}
}




