• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that looks pretty cool thanks ill try that
reply
    Bookmark Topic Watch Topic
  • New Topic