Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. public void somar (View v){
  2.  
  3. EditText odd1 = (EditText) findViewById(R.id.editText7);
  4. String stringodd1 = odd1.getText().toString();
  5.  
  6. EditText odd2 = (EditText) findViewById(R.id.editText8);
  7. String stringodd2 = odd2.getText().toString();
  8.  
  9. EditText odd3 = (EditText) findViewById(R.id.editText9);
  10. String stringodd3 = odd3.getText().toString();
  11.  
  12. EditText montante = (EditText) findViewById(R.id.editText12);
  13. String stringmontante = montante.getText().toString();
  14.  
  15.  
  16. if (stringodd1.trim().isEmpty() || stringodd2.trim().isEmpty() || stringodd3.trim().isEmpty())
  17. {
  18. Toast.makeText(getApplicationContext(), "Campos em branco",
  19. Toast.LENGTH_LONG).show();
  20. }
  21. else
  22. {
  23.  
  24. double valorodd1 = Double.parseDouble(stringodd1);
  25. double valorodd2 = Double.parseDouble(stringodd2);
  26. double valorodd3 = Double.parseDouble(stringodd2);
  27. double valormontante = Double.parseDouble(stringmontante);
  28.  
  29.  
  30. double resu = valorodd1 * valorodd2 * valorodd3 * valormontante;
  31.  
  32.  
  33.  
  34. TextView resultado = (TextView) findViewById(R.id.textView15);
  35. resultado.setText (resu + "€" );
  36.  
  37.  
  38.  
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement