I am finishing up a program becose I am going on vacation next week. However there is still one thing I can't get to work. Even though I already asked help here. But that topic is already 'old' now. So here we go again.

I have a HashMap, and now I got a for loop to look up the string (AFVDSQ) in HashMap. Now these 'numbers' respresent a value. And I would like to get the A * F * V * D * S * Q. But i don't know how to do that. And all my attemps fail... :(-:

And in this 'for' loop it looks at the string and takes out the number from Hashmap.
Like an A represents the value: 71.0788.
What I would like is that the string (example) ARR, becomes: 71.0788 * 156.1875 * 156.1875 = ......(answer I need)

07-01-2011, 06:49 PM

Norm

Get the value String for each letter from the HashMap, use a parse method (See Double) to convert the String to a number and multiply those numbers to get the product you need.

Quote:

becomes: 71.0788 * 156.1875 * 156.1875

Is that at String: "71.0788 * 156.1875 * 156.1875"
or does it represent a product of the three numbers?

07-01-2011, 07:40 PM

Lund01

This is the String we have: ARR
This is what I still need to add: 71.0788 * 156.1875 * 156.1875 = ......(end product I need)

These strings can be 3 letters long or 25.
There is not a solid length.
Also with this code I can look them up:

Define a variable before the loop equal to a value (say 1 for multiplication, 0 for addition), and through each iteration use Norm's advice to get the value from the map, parse it to double, then perform the math operation on the value defined prior to the loop.