aspose file tools
The moose likes Java in General and the fly likes 2darray identify part of array and add its value to total Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "2darray identify part of array and add its value to total" Watch "2darray identify part of array and add its value to total" New topic
Author

2darray identify part of array and add its value to total

Mark Hughes
Ranch Hand

Joined: Jul 14, 2006
Posts: 145
Hey guys,
have a 2darray which looks like;
circle red 0.2
square green 1.1
circle blue 2.0

Now i can search the array for say shape circle, but i also want to total the value of circle so above will become 2.2 when added up, at the moment my code just total the number of circle so above would be 2 circles, can some one please show me how i might edit my code to total value opposed to how many;

do you think i would have to put some kind of for loop within my if statement to total value of circle or square ect.

Thanks
mark
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
hey

is the order fixed (is it always "shape", "color", "value") ?

if yes, then you can simplify your code. i give you some code parts below which hopefully get you started....






pascal
Mark Hughes
Ranch Hand

Joined: Jul 14, 2006
Posts: 145
that looks pretty cool thanks ill try that
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: 2darray identify part of array and add its value to total
 
Similar Threads
Stuck on a question
Print attributes of ListArray in reverse
2darray counter
array of array help
User input into array