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


0