This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I have 3 arrays that were filled from a file. The first column is breakfast, the second column is lunch, and the third column is dinner. But now I have to get the totals for each day (or row), and I don't know how to do that without having a multi dimensional array since I already have 3 arrays filled.
The file looks like this, the numbers correspond to calories, each row is a day:
200 1000 800
450 845 1200
800 250 400
0 1500 1800
600 500 1000
700 1400 1700
675 400 900
I'm not asking for a code, just a suggestion or idea how to get around this :S I know how to add rows and columns in 2d arrays but this threw me off.
Joined: Sep 02, 2011
So I got the sum for the first row using this... haha
int first = 0;
int sum = 0;
sum += breakfast[first] + lunch[first] + dinner[first];
but how could I get so it goes through the rest of the indexes without retyping or copying and pasting the code 7 times...?