-1
public class Calculadora {
public float valor1;
public float valor2;
public float valor3;
public Calculadora(float valor1) {
}
public Calculadora(float valor1, float valor2){
}
public Calculadora(float valor1, float valor2, float valor3){
}
public float soma(){
return valor1 + valor2 + valor3;
}
public float subtracao(){
return valor1 - valor2 - valor3;
}
public float multiplicacao(){
return valor1 * valor2 * valor3;
}
public float divisao(){
return (valor1 / valor2 / valor3);
}
}
public class TesteMain {
public static void main(String[] args) {
Calculadora c1 = new Calculadora(23, 32, 54);
System.out.println("A soma dos n�meros �: " + c1.soma());
System.out.println("A subtra��o dos n�meros �: " + c1.subtracao());
System.out.println("A multiplica��o dos n�meros �: " + c1.multiplicacao());
System.out.println("A divis�o dos n�meros �: " + c1.divisao());
}
}
What is the result? Why not put the variables as parameters of the methods instead of attributes of the classes?
– leandro.dev
pq was thus specified in an exercise, I was able to run "this.valor1 = valor1;' and so with the other variables in the last constructor.
– Prince Neres