Results 1 to 2 of 2
  1. #1
    Dimitri is offline Member
    Join Date
    Sep 2011
    Posts
    6
    Rep Power
    0

    Lightbulb Values of elements using regular expression

    Hello. Please help! do not get.

    File in.properties (pairs key=value) contains some sequence of lines.
    Let the element with key indexi has the value j (i=1..n, j=1..m – natural numbers without leading zeros). It determines the index of an element with name valueij (j = indexi) you should work with.
    1) Print the sum of values of elements, having the key valueij (see examples below).
    2) Print the number of index elements with “errors” (i, j – unnatural numbers; no correct value-element for sum).

    The example of the file in.properties:
    index1 = 3
    value11=qw
    value12=4
    value13 = 5.1
    value14=2.7
    index2=15
    value21=
    value22=
    value23=
    value24=k
    value25=5
    index3=1
    value31= 3.14
    value32=fgh
    value33=5
    index4=0
    value41=
    value42=e1
    value43=2
    value44=3
    index5=b
    value51=d
    value52=e

    Output:
    sum = 8.24
    error-lines = 3


    I read from a file as follows:

    Java Code:
    ResourceBundle rb = ResourceBundle.getBundle("in");
    Enumeration<String> keys = rb.getKeys();
    String key;
    while(keys.hasMoreElements()) {
     key = keys.nextElement();
     ...
    }
    How now?
    I cant do the third day. Please, help!

    P.S. Sorry for my english

  2. #2
    Dimitri is offline Member
    Join Date
    Sep 2011
    Posts
    6
    Rep Power
    0

    Default Re: Values of elements using regular expression

    Please help.
    Last edited by Dimitri; 10-24-2011 at 04:36 PM.

Similar Threads

  1. Regular Expression Help
    By niketanand in forum Advanced Java
    Replies: 1
    Last Post: 06-24-2011, 05:56 PM
  2. regular expression
    By ehsansad in forum New To Java
    Replies: 8
    Last Post: 03-18-2011, 03:23 PM
  3. regular expression
    By prof.deedee in forum JDBC
    Replies: 3
    Last Post: 02-19-2010, 12:15 PM
  4. regular expression
    By QkrspCmptPop in forum Advanced Java
    Replies: 8
    Last Post: 01-20-2010, 04:55 AM
  5. regular expression
    By ras_pari in forum Advanced Java
    Replies: 27
    Last Post: 10-07-2009, 01:25 PM

Posting Permissions

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