fork download
  1. class Main {
  2. public static void main(String[] args) {
  3. String[][] compras = new String[][] {
  4. { "item 1", "1.70" }, { "item 2", "39.90" }, { "item 3", "9.90" }, { "item 4", "4.90" },
  5. { "item 5", "7.90" } };
  6. int soma = 0;
  7. for (int i = 0; i < compras.length; i++) soma = (int)(soma + Double.parseDouble(compras[i][1]));
  8. System.out.println("Total das compras: R$ " + soma);
  9. }
  10. }
  11.  
  12. //https://pt.stackoverflow.com/q/504945/101
Success #stdin #stdout 0.1s 48388KB
stdin
Standard input is empty
stdout
Total das compras: R$ 60