class Main {
public static void main
(String[] args
) { { "item 1", "1.70" }, { "item 2", "39.90" }, { "item 3", "9.90" }, { "item 4", "4.90" },
{ "item 5", "7.90" } };
int soma = 0;
for (int i
= 0; i
< compras.
length; i
++) soma
= (int)(soma
+ Double.
parseDouble(compras
[i
][1])); System.
out.
println("Total das compras: R$ " + soma
); }
}
//https://pt.stackoverflow.com/q/504945/101
Y2xhc3MgTWFpbiB7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CgkJU3RyaW5nW11bXSBjb21wcmFzID0gbmV3IFN0cmluZ1tdW10gewoJCQkJeyAiaXRlbSAxIiwgIjEuNzAiIH0sIHsgIml0ZW0gMiIsICIzOS45MCIgfSwgeyAiaXRlbSAzIiwgIjkuOTAiIH0sIHsgIml0ZW0gNCIsICI0LjkwIiB9LAoJCQkJeyAiaXRlbSA1IiwgIjcuOTAiIH0gfTsKCQlpbnQgc29tYSA9IDA7CgkJZm9yIChpbnQgaSA9IDA7IGkgPCBjb21wcmFzLmxlbmd0aDsgaSsrKSBzb21hID0gKGludCkoc29tYSArIERvdWJsZS5wYXJzZURvdWJsZShjb21wcmFzW2ldWzFdKSk7CgkJU3lzdGVtLm91dC5wcmludGxuKCJUb3RhbCBkYXMgY29tcHJhczogUiQgIiArIHNvbWEpOwoJfQp9CgovL2h0dHBzOi8vcHQuc3RhY2tvdmVyZmxvdy5jb20vcS81MDQ5NDUvMTAx