Results 1 to 8 of 8
Thread: Float question
- 07-06-2011, 05:26 PM #1
Float question
I am trying a new solution on a problem i have.
i have created a float.
Now I have this String:Java Code:float A = (float)1.23f; float B = (float)3.11f;
How do I get the the folowing output:Java Code:String string1 = "ABA";
String mass = 1.23 + 3.11 + 1.23 = 5.57
Java Code:int length = string1.length(); if (length >= 0) { //System.out.println("test"); }
- 07-06-2011, 05:39 PM #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.
- 07-06-2011, 06:55 PM #3
Question 1
So I am trying this one now:
But how do i make it something wit a 1.23?Java Code:Map <String, Integer> x = new LinkedHashMap <String, Integer>(16, 0.75f, true); x.put("A", 1);
My 2nd question:
But then I still have only loose values.Java Code:for (int i = 0; i < string1.length(); i++) { String ss = string1.substring(i, i +1); System.out.println(x.get(ss).intValue()); }
How do I count then with each other?Last edited by Lund01; 07-06-2011 at 07:08 PM.
- 07-06-2011, 06:59 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).
- 07-06-2011, 07:21 PM #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.
- 07-06-2011, 07:24 PM #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.
- 07-06-2011, 07:34 PM #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.
As this program is gonna be "free to download to everyone".
P.s. I never give up!
(Just need more time.)
- 07-06-2011, 07:36 PM #8
Similar Threads
-
Error in float value
By JMaste in forum New To JavaReplies: 5Last Post: 07-11-2010, 04:08 PM -
string to float
By Sungron in forum New To JavaReplies: 3Last Post: 02-02-2010, 09:23 AM -
String to Float
By durahman in forum New To JavaReplies: 2Last Post: 02-12-2008, 12:17 AM -
Float to String
By mew in forum New To JavaReplies: 4Last Post: 12-29-2007, 05:08 PM -
Class float
By Peter in forum New To JavaReplies: 1Last Post: 07-08-2007, 01:17 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks