Android - Fallo en mi calculadora

 
Vista:

Fallo en mi calculadora

Publicado por nelson (1 intervención) el 07/06/2017 12:48:18
Buenos dias me gustaria saber si alguien sabe tego el fallo de mi calculadora de consumo electrico, esta todo bien puesto en numberDecimal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
public class MainActivity extends AppCompatActivity {
 
    Button btnCalcular;
    EditText etVatios ,etHoras, etPrecio ,etDias;
    TextView tvResultado;
 
    int valor = 1000;
    double igual;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        btnCalcular = (Button) findViewById(R.id.btnCalcular);
 
        etVatios = (EditText) findViewById(R.id.etVatios);
        etHoras = (EditText) findViewById(R.id.etHoras);
        etPrecio = (EditText) findViewById(R.id.etPrecio);
        etDias = (EditText) findViewById(R.id.etDias);
 
        tvResultado = (TextView) findViewById(R.id.tvResultado);
 
    }
    public void btnCalcular(View v) {
        if (etVatios.getText().toString().isEmpty()) {
            tvResultado.setText("No se a escrito los vatios");
        }
        else {
            int aux1 = Integer.valueOf(etVatios.getText().toString());
            int aux2 = Integer.valueOf(etHoras.getText().toString());
            double aux3 = Integer.valueOf(etPrecio.getText().toString());
            int aux4 = Integer.valueOf(etDias.getText().toString());
 
             double igual = aux1 / valor * aux2  * aux3   * aux4 ;
            tvResultado.setText(igual  + "Euros");
        }
    }}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Alejandro
Val: 3
Ha disminuido su posición en 7 puestos en Android (en relación al último mes)
Gráfica de Android

Fallo en mi calculadora

Publicado por Alejandro (2 intervenciones) el 07/06/2017 23:28:29
A mi me salio asi:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
public class adsCalculadora extends AppCompatActivity {
 
    Button btnCalcular;
 
    EditText etVatios ,etHoras, etPrecio ,etDias;
 
    TextView etResultado;
 
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ads_calculadora);
 
        btnCalcular = (Button) findViewById(R.id.btnCalcular);
        etVatios = (EditText) findViewById(R.id.etVatios);
        etHoras = (EditText) findViewById(R.id.etHoras);
        etPrecio = (EditText) findViewById(R.id.etPrecio);
        etDias = (EditText) findViewById(R.id.etDias);
        etResultado = (TextView) findViewById(R.id.etResultado);
        btnCalcular.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Calcular();
            }
        });
 
    }
 
    public void Calcular() {
        if (!etVatios.getText().toString().isEmpty() && !etHoras.getText().toString().isEmpty() && !etPrecio.getText().toString().isEmpty() && !etDias.getText().toString().isEmpty()) {
 
            int aux1 = Integer.valueOf(etVatios.getText().toString());
            int aux2 = Integer.valueOf(etHoras.getText().toString());
            double aux3 = Integer.valueOf(etPrecio.getText().toString());
            int aux4 = Integer.valueOf(etDias.getText().toString());
 
            double result = (aux1 / 1000) * aux2  * aux3   * aux4 ;
 
            etResultado.setText(result  + "");
 
        }
 
    }
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar