1. ## Float question

I am trying a new solution on a problem i have.
i have created a float.

Java Code:
```
float A = (float)1.23f;
float B = (float)3.11f;```
Now I have this String:
Java Code:
```
String string1 = "ABA";```
How do I get the the folowing output:
String mass = 1.23 + 3.11 + 1.23 = 5.57

Java Code:
```
int length = string1.length();
if (length >= 0) {
//System.out.println("test");
}```

2. It appears that you want to scan the String: "ABA" and use the letter to get a value.
A Map will allow you to do this.
For the key = the letter, the value is the class object (your class) with a String representing the value and the numberic value.
Get the letters one by one and get the object from the Map. Use the String part to build the mass String and use the numberic value to do the summing.

3. Question 1

So I am trying this one now:

Java Code:
```
Map <String, Integer> x = new LinkedHashMap <String, Integer>(16, 0.75f, true);
x.put("A", 1);```
But how do i make it something wit a 1.23?

My 2nd question:

Java Code:
```
for (int i = 0; i < string1.length(); i++) {
String ss = string1.substring(i, i +1);
System.out.println(x.get(ss).intValue());
}```
But then I still have only loose values.
How do I count then with each other?
Last edited by Lund01; 07-06-2011 at 07:08 PM.

4. What do you want done with the 1.23?
I assume that is the contents of a double or float variable. Or is it a String? "1.23"
There are wrapper classes for float(Float) and double(Double) just like int(Integer).

5. The only thing I need is to calculate a peptide mass from each peptide.
And a peptide looks like a string of letters.
So if you would have: ABA, I would like to have as output 5.57.

Input: ABA
Output 5.57.
That is all.

6. You need a design for your application. You have input data and a desired result.
You need to connect the two. I suggested an approach. Have you given up on it already?

There is nothing in java to handle peptide mass.

7. To be honest I am working on this already a few weeks, and i am nearly there (for the whole program).
The problem is that there is nowhere softare availeble to do this.
If we need to do this manually it will take ages, so it is not an option.

Lets say we only need to invent the wheel one time.

P.s. I never give up!
(Just need more time.)

8. Ok. Keep going.
Come back if you have any more problems.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•