# Print the sum of elements, determined by zero elements

• 10-19-2011, 09:54 PM
Dimitri
Print the sum of elements, determined by zero elements
Hello, guys.
I have next csv file:
3;qw;4;5.1;2.7
15;;;k;5
1;3.14;fgh;5
0;;e1;2;3
-2.3;a;b;c
b;d;e

And i added this data from file to String array[][] and i need print the sum of elements, determined by zero elements. Create this result in the string. The output format see in the example: sum = 5.1 + 3.14 + 0 = 8.24

How do I do, I understand the algorithm, but the syntax does not know. Please, help
• 10-20-2011, 12:18 AM
Junky
Re: Print the sum of elements, determined by zero elements
Quote:

Originally Posted by Dimitri
i need print the sum of elements, determined by zero elements.

I have no idea what that means.
• 10-20-2011, 12:32 AM
Dimitri
Re: Print the sum of elements, determined by zero elements
File in.csv (text data separated by semicolon) contains some sequence of lines with any number of elements in each line.
Let the initial element of any line has an index 0. Its value determines the index of an element in the line you should work with.
1) Print the sum of elements, determined by zero elements. Create this result in the string. The output format see in the example below.
2) Print the number of lines with “errors”.

The example of the file in.csv:
3;qw;4;5.1;2.7
15;;;k;5
1;3.14;fgh;5
0;;e1;2;3
-2.3;a;b;c
b;d;e
Output:
sum = 5.1 + 3.14 + 0 = 8.24
error-lines = 3
• 10-20-2011, 12:42 AM
Junky
Re: Print the sum of elements, determined by zero elements
<lightbulb>
I see what the problem is.