How to substract an int from a String?

Hi,
Here is my problem,
I have to substract 4 integers out of a single string (in a single input using the JOptionPane.showInputDialog)
these 4 integers are seberated by spaces (any number of spaces)
I have to sign each number to an int variable
also I have to multiply these 4 integers with doubles to get a final double variable result
I need urgent help please
(hint: it's about string manuplation)
Thanks

Hi,
Here is my problem,
I have to substract 4 integers out of a single string
(in a single input using the
JOptionPane.showInputDialog)
these 4 integers are seberated by spaces (any number
r of spaces)
I have to sign each number to an int variable
also I have to multiply these 4 integers with doubles
to get a final double variable result I have no idea what you're asking. Can you clarify? Maybe provide some sample input and what the output will be.
I need urgent help please I promise you, nobody here cares about your urgency, and mentioning it is guaranteed NOT to get you help any faster. If it has any effect at all, it will be the opposite--some people might decide to delay or skip answering your question simply out of irritation at you mentioning your urgency.
(hint: it's about string manuplation)Yeah. We got that, thanks.

Similar Messages

  • How to get a char from a String Class?

    How to get a char from a String Class?

    Use charAt(int index), like this for example:
    String s = "Java";
    char c = s.charAt(2);
    System.out.println(c);

  • How to create session id from different string controls

    how to create session id from different string controls

    fais,
    Please create the VI you are talking about and save some default data into all of the controls. Also on the front panel, place the session ID that should be generated by that data. Now, post your VI to a response so I can download it. I can then take this VI and help you create the functionality. (Please post what version of LabVIEW you are using.)
    My guess it that you are going to need to use a good number of string concatenations as well as a few string indexes to get parts of strings out. As for the date, you can use a Property node with the Numeric Text.Text property to get the actual string displayed on the front panel for the date and parse out the parts that you want.
    Randy Hoskin
    Applications Engineer
    National Instruments
    h
    ttp://www.ni.com/ask

  • How can i store values from my String into Array

    Hi guys
    i wants to store all the values from my string into an array,,,, after converting them into intergers,,,, how i can do this becs i have a peice of code which just give me a value of a character at time,,,,charat(2)...BUT i want to the values from String to store in an Array
    here is my peice of code which i m using for 1 char at time
    int[] ExampleArray2 = new int[24];
    String tempci = "Battle of Midway";
    for(int i=0;i>=tempci.length();i++)
    int ascii = tempci.charAt(i); //Get ascii value for the first character.

    public class d1
         public static final void main( String args[] )
              int[] ExampleArray2 = new int[24];
              String tempci = "Battle of Midway";
              for(int i=0;i<tempci.length();i++)
                   int ascii = tempci.charAt(i);
                   ExampleArray2=ascii;
              for(int i=0;i<ExampleArray2.length;i++)
                   System.out.println(ExampleArray2[i]);

  • How to extract specific line from a string

    Hi guys.
    I?m starting to work with java...
    i have the following data inside a string variable:
    0 rows inserted.
    0 rows updated.
    0 rows ignored.
    98 rows marked as deleted.
    0 rows have no country.
    3345 rows have no geo.
    0 rows are invalid.
    what i want to do i to extract the number of rows marked as delete.
    I think that i figured out how to extract the number from this line :"98 rows marked as deleted."
    but how do i get to that line?
    I hope you can Help me. Thanks.

    the string is the result from a Function... this function gets the info from a store procedure...
                   rta = "Results for " + dh.getSource() + " source:\n" +
    dh.getInsertedCount() + " rows inserted.\n" +
    dh.getUpdatedCount() + " rows updated.\n" +
    dh.getIgnoredCount() + " rows ignored.\n" +
                   dh.getDeletedCount() + " rows marked as deleted.\n" +
                   dh.getNoCtryCnt() + " rows have no country.\n" +
                   dh.getNoGeoCnt() + " rows have no geo.\n" +
                   dh.getInvalidCnt() + " rows are invalid.\n";
    i can?t change this function...
    so i need to work with the returned value...
    i what thinking to use the following method to extract te number...
    private int GetNumericValue(string sVal)
    int iFirst, iCharVal, iEnd;
    int iMult = 1, iRet = 0;
    char[] aNumbers = "1234567890".ToCharArray();
    iFirst = sVal.IndexOfAny(aNumbers);
    iEnd = sVal.LastIndexOfAny(aNumbers);
    if (iEnd < 0)
    return 0;
    string subStr = sVal.Substring(iFirst, iEnd - iFirst + 1);
    iEnd = subStr.Length - 1;
    while (subStr.Length > 0)
    iCharVal = int.Parse(subStr[subStr.Length-1].ToString());
    iRet += iMult * iCharVal;
    iMult *= 10;
    if (iEnd <= 0)
    break;
    subStr = subStr.Substring(0, subStr.Length - 1);
    iEnd = subStr.LastIndexOfAny(aNumbers);
    subStr = sVal.Substring(iFirst, iEnd + 1);
    return iRet;
    but i still need the 4rd line to extract the number

  • How to remove HTML tags from a String ?

    Hello,
    How can I remove all HTML Tags from a String ?
    Would you please to give me a simple example ?
    Best regards,
    Eric

    Here's some code I cooked up. I have created an object that processes code so that it can be incorporated directly into a project. There is some redundancy so that the it can be used in more than one way. Depending on your situation you might have to make the condition statement a little more sophisticated to catch stray ">" tags.
    I have also included a Tester application.
    //This removes Html tags from a String either by submitting the String during construction and then
    // calling getProcessedString() or
    // by simply calling " stringwithoutTags=removeHtmlTags(stringWithTagsSubmission); "
    //Note: This code assumes that all"<" tags are accompanied by a ">" tag in the proper order.
    public class HtmlTagRemover
         private String stringSubmission,processedString,stringBeingProcessed;
         private int indexOfTagStart,indexOfTagEnd;
         public HtmlTagRemover()
         public HtmlTagRemover(String s)
              removeHtmlTags(s);          
         public String removeHtmlTags(String s)
              stringSubmission=s;
              stringBeingProcessed=stringSubmission;
              removeNextTag();
              return processedString;
         private void removeNextTag()
              checkForNextTag();
              while((!(indexOfTagStart==-1||indexOfTagEnd==-1))&<indexOfTagEnd)
                   removeTag();
                   checkForNextTag();
              processedString=stringBeingProcessed;
         private void checkForNextTag()
              indexOfTagStart=stringBeingProcessed.indexOf("<");
              indexOfTagEnd=stringBeingProcessed.indexOf(">");
         private void removeTag()
              StringBuffer sb=new StringBuffer("");
              sb.append(stringBeingProcessed);
              sb.delete(indexOfTagStart,indexOfTagEnd+1);
              stringBeingProcessed=sb.toString();
         public String getProcessedString()
              return processedString;
         public String getLastStringSubmission()
              return stringSubmission;
    public class HtmlRemovalTester
         static void main(String[] args)
              String output;
              HtmlTagRemover h=new HtmlTagRemover();
              output="The processed String: "+h.removeHtmlTags("<Html tag>This is a test<another Html tag> string<yet another Html tag>.");
              output=output+"\n"+" The original string:"+h.getLastStringSubmission();
              System.out.print(output);

  • Extract int from a string

    Hi,
    I am curious if there is an easy way to extract an int value from a String.
    For example, "Rb23" to get 23. The length of the part in front of the integer is variable.
    Thanks

    this seems to work:
    public int extract(String s) {
         String result = "";
         char c[] = s.toCharArray();
         int j = c.length-1;
         if (!Character.isDigit(c[j])) {
              return 0;
         do {
              result+=c[j--];
         } while (j > 0 && Character.isDigit(c[j]));
         return Integer.parseInt(new StringBuffer(result).reverse().toString());
    }it will return 0 if no numbers are found at the end of the string

  • How to convert an int variable into String type

    hi everybody
    i want to know how to convert an interger variable into string variable
    i have to implement a code which goes like this
    Chioce ch;
    for(int i=0;i<32;i++)
    // here i need a code to convert the int variable i into a string variable
    ch.add(String variable);
    how do i convert that int variable i into a String type variable??
    can anyone help me?

    Different methods:
    int a;
    string s=a+"";or
    String.valueOf(int) is the better option because Int.toString() generated an intermediate object to get the endresult
    Ema

  • How can I remove vbCrLf from a string?

    How do I delete all instances of vbCrLf from a string?
    Thanks in advance.

    For reading lines from a text file try something along these lines:
    Dim tfr As System.IO.StreamReader = My.Computer.FileSystem.OpenTextFileReader(My.Application.Info.DirectoryPath & "\backups.dat")
    Dim TheFileLines As New List(Of String)
    While Not tfr.EndOfStream
    TheFileLines.Add(tfr.ReadLine())
    End While
    tfr.Close()
    tfr.Dispose()

  • How to convert an int to a String

    Hi, just wanting to know is anyone could help me with convertin a primitive int into a String, currently I have
    String mod = Integer.valueOf(n);
    but with this i keep getting an error which says, - cannot resolve symbol - method valueOf(int)
    Can anyone please help me. thanks.

    it should be
    String mod = Integer.toString(n);

  • How to use create-nodeset-from-delimited-string()

    Hi All,
    I am getting the input data as following
    name rollno sub
    Anu 1 Maths|science|social
    and the output should be as follows:
    name rollno sub
    Anu 1 Maths
    Anu 1 Science
    Anu 1 Social
    I need to implememt this by using oraext:create-nodeset-from-delimited-string() in XSLT Pls help me out in resolving this issue
    Regards,
    Anasuya

    can u elaborate the query with ur input xml and output xml for clear understanding instead of
    name rollno sub
    Anu 1 Maths|science|social
    and the output should be as follows:
    name rollno sub
    Anu 1 Maths
    Anu 1 Science
    Anu 1 Social
    check the following links it might help u
    http://www.soabyte.com/2011/01/delimited-string-to-xml-nodeset.html
    Edited by: olety on Nov 2, 2011 2:29 AM

  • How to convert an int array to string array?

    Hi,
    Can anyone please help me with this question?
    int number={4,6,45,3,2,77};
    I like to convert this into a list and sort
    List mylist = Arrays.asList(number);
    Collections.sort(mylist);
    But first I need to convert the int array to String array.
    Please advise. Thanks.

    If you want to convert your int array to a String array, you have no choice but doing a conversion element by element in a for loop.
    However, if the sort method doesn't behave as desired, you can use the one with 2 parameters, the second parameter being a comparator class.
    Check the javadoc for more information : http://java.sun.com/j2se/1.3/docs/api/java/util/Collections.html
    /Stephane

  • How to Extract particular field from a string ( Mapping)

    how to exteract the particular field from the given string:
    ProcessEmp this element has a below string subfields.
    <ProcessEmp>&lt;?xml version="1.0" encoding="utf-8" standalone="no"?&gt;
    &lt;Employee PersonnelNumber="11111" FirstName="String" MiddleName="String" LastName="String" Department="String" Group="" SapUserID="10flname" EmailAddress="[email protected]" DefaultPassword="*" Status="Success" /&gt;</ProcessEmp>
    how to extract only PersonalNumber, department, EmailAddress from above ProcessEmp into 3 diff fields.
    Thanks
    dhanush.

    Hi,
    You are receiving XML message within a field. To access a particular field from that XML message, you could create a User Defined Function, as suggested by many already.
    You could write UDF using some of the String operation functions. This could include following:
    1. If you need to access field Employee PersonnelNumber, you could get last index of that within string using function lastIndexOf(String str). Pass string "Employee PersonnelNumber="" for this function.
    2. This function would return an index of rightmost occurance of this string.
    3. after this you could get the index of next occurance of ", as the value of field is within quotes. You could use function indexOf(int ch, int fromIndex) for getting the same. You would pass Character as " and index as the one received by previous function.
    4. Now you have index for starting and ending point of value string for desired field.
    5. After this you could use substring(int beginIndex, int endIndex) function by passing first and second index values to retrieve the needed string, which contains value of field.
    Hope this would be helful.
    Thanks,
    Bhavish
    Reward points if comments found helpful:-)

  • How to remove empty char from a string

    Hi,
    In my code I should get numeric int numbers and convert them to 1 and 0 , concatenate thm to make an string ( 8 chars) . the problem I have is the empty chars as result of conversion from number to string
    so lets say pxiAnaIn=1 dutVdd=2 and dutOut=5 so then the output should be 10110001 but now the output is 10110  1 . could you please let me know how can I fix this problem
    thanks

    tintin_99 wrote:
    Hi,
    In my code I should get numeric int numbers and convert them to 1 and 0 , concatenate thm to make an string ( 8 chars) . the problem I have is the empty chars as result of conversion from number to string
    so lets say pxiAnaIn=1 dutVdd=2 and dutOut=5 so then the output should be 10110001 but now the output is 10110  1 . could you please let me know how can I fix this problem
    thanks
    You could make your life a little easier and only use 1 format string.  Use "%03b%02b%03b" for the format string.  You can then expand the format string to allow multiple inputs.  You will do the job of 4 functions with just 1.
    "%3b" just says to give 3 spaces for the binary number.  But any preceding 0s will be turned into spaces.  Adding the 0 in there tells the format string to prepend 0s instead of using spaces.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Picking an int from a string

    I have to get the user to input a name and five int's (scores for a test) using a scanner
    so it would look like this "Casey 98 96 95 84 92"
    how would I pick the integers out of that?

    This is what the assingment says
    Repeatedly (i.e. in a loop) process the input file, placing the results into the output file in a formatted way. In particular:
    Read the student name and five exam scores for that student from the input file. You may assume that each line of the file starts with a String representing the student's (last) name, followed by whitespace followed by the five exam scores, each separated by whitespace. Your program does not have to handle the case where there are fewer that six items in the line or the case where the information in the line is not in the order specified.
    Does that change anything?

Maybe you are looking for

  • How to write data from planning folder into a planning cube in BPS

    Hi All, I have an issue in writing data from planning folder to planning cube. I updated the excel sheet in planning folder in UPSPL tcode. After clicking on save button in the excel sheet the data did not get updated into the cube. I set the real ti

  • Acrobat 9 Trial - Scanning Issue

    Hi, Just want to check that I definitely have an IT issue. Is scanning supported in the trial version? When I select File>Create PDF>From Scanner and choose any type of document I get two choices, a TWAIN driver and a WIA-HP driver. Selecting either

  • IChat using external iSight on iMac 24" 2009

    iChat using external iSight on iMac 24" 2009 I'm trying to use an external iSight camera in iChat instead of the built-in one but when connected iChat just gives a beach ball. Searching for similar issues mentions that both cameras should be availabl

  • Syncing Issues - playlists on Itouch getting erased

    I am still trying to get the hang of syncing. Sometimes I do it right and nothing that is already on my Itouch gets altered. However, lately, whenever I sync, my On-the-Go and Genius playlists get erased. It's weird because none of the other playlist

  • Can't render in Premiere 3.0

    Video is DV.  Program is 41 minutes.  I have selected the work area, clicked on timeline - render work area and let it roll.  Only the first 2 minutes show the green line and a few little sections through out.  There is no red line.  I've exported to