Калькулятор римских цифр не будет работать, когда результат калькулятора будет отрицательным, я, честно говоря, не знаю, как это исправить. Когда калькулятор выдает положительное значение все работает нормально например результат будет выглядеть так
please enter the two two integer values that you want to vomplete the operation with
> 33
> 44
please enter the operation you want preformed
> +
Here is the answer 77 negative roman numeral value Here is the answer in roman numerals
LXXVII
Код здесь:
public static void main(String[] args) {
System.out.println("please enter the two two integer values that you want"
+ " to vomplete the operation with ");
Scanner scan = new Scanner(System.in);
int first = scan.nextInt();
int sec = scan.nextInt();
System.out.println(" please enter the operation you want preformed");
String opera = scan.next();
System.out.println(" Here is the answer");
int value = Acalc(opera, first, sec);
String roman = Roman(value);
System.out.println(" Here is the answer in roman numerals ");
System.out.println(roman);
}
public static int Acalc(String opera, int n1, int n2){
int result = 0;
//Write the calulator
if (opera.equals("+")) {result=n1+n2;}
if (opera.equals("-")) {result=n1-n2;}
if (opera.equals("*")) {result=n1*n2;}
if (opera.equals("/")) {result=n1/n2;}
System.out.println(result);
return result;
}
public static String Roman(double input){
String s = "";
if (input <1 || input < 999)
System.out.println("negative roman numeral value ");
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;
}
if (input <1 || input < 999)
- person Paul Hicks   schedule 23.12.2014