-4
import java.util.Scanner;
public class desafio {
public static void main(String args[]) {
char op;
float soma;
float mult;
float sub;
float div;
float num;
Scanner entrada = new Scanner(System.in);
op = entrada.next().charAt(0);
switch (op) {
case '+': while (num = entrada.nextFloat() != 0) {
soma += num;
}
break;
case '-': while (num = entrada.nextFloat() != 0) {
sub = entrada;
sub -= num;
}
break;
case 'x': while(num = entrada.nextFloat() != 0) {
mult = 1;
mult *= num;
}
case '/': while(num = entrada.nextFloat() != 0) {
div = 1;
num = entrada;
}
}
}
}
You’re splitting right?
– rray
div = 1?; you are sure of this?
– WMomesso
Actually I sent it before changing the last operation however some strange errors appear. (I’m starting in java). "incompatible types".
– Lucas Aranha
First you need to say what you want to do. Even so: you did not initialize the sum variable before using it, in sum += num. In your division you are just doing: num = input. Maybe that’s not what you want.
– Rodrigo Oliveira