I can not perform the indicated operations [closed]

-2
  

Construct a program that, given 2 20-position integer vectors, perform the respective operations indicated by a third 20-position character vector also provided by the user, containing the four arithmetic operations in any combination, storing the results in a fourth vector .

public class Funcao {

    int v1[] = new int [20];
    int v2[] = new int [20];
    String oper [] = new String[20];
    double result [] = new double [20];


int i;
for (i=0;i<20;i++){
v1[i] = Integer.parseInt(JOptionPane.showInputDialog("Digite "+(i+1)+" operando"));
oper[i] = JOptionPane.showInputDialog("Digite "+(i+1)+" operador(+,-,*,/)");
v2[i] = Integer.parseInt(JOptionPane.showInputDialog("Digite "+(i+1)+" operando"));
        }

    }
    
asked by anonymous 13.12.2017 / 13:17

1 answer

-1
for(int i=0; i<20; i++){
        switch(oper[i]){
            case "+":
                result[i] = v1[i] + v2[i];
                break;
            case "-":
                result[i] = v1[i] - v2[i];
                break;
            case "*":
                result[i] = v1[i] * v2[i];
                break;
            case "/":
                result[i] = v1[i] / v2[i];
                break;
            default:
                System.out.println("Operador inválido");
        }
    }
    
13.12.2017 / 13:19