Finding the average of all the values stored in a two dimentional array

public int avg(int[][] numbers2){
    int sum = 0;
    float avg = 0;
    for(int r = 0; r < numbers2.length; r++)
      for(int c = 0; c < numbers2[r].length; c++){
          sum += numbers2[r][c];
      }So I have this code that of course finds the sum of all the values stored in the array int[][] numbers. What I am having an issue with is finding the average of the numbers. When I attempt to use:
avg = sum / numbers2.length; I get the sum / 3 because my array looks like:
int[][] numbers2 = {{1, 2, 3},
                            {4, 5, 6},
                            {7, 8, 9}
                                      };Any ideas on what I should do or where I could find information on this process?

2 dimensional arrays have 2 lengths:
myArray.length and myArray[0].length
The first one I believe is fixed, the second one may vary from row to row. But if you know that it won't vary, then you can just use the [0] row length.

Similar Messages

  • How/where to get the values stored in these two structure fields?

    hi
       need your help to find out where the following two fields get stored in tables...or is there any fm or bapi to get the data stored in these two fields?
    1) Create Scheduling agreement:
    Tcode: ME31L
    Field label - Agreement type
    Field name - EVART
    Structure - RM06E
    2) Purchase order display:
    Tcode: ME23
    Provide any Purchase order craeted already (where release strategy is implemented)
    Select the line item & click release strategy icon at the top.
    You will find a new pop-up menu. In that place the cursor on the startegy code like
    Final release or XX or etc.
    Field name - ANZEF
    Structure - RM06B
    Sathish. R

    Hello Sathish:
    1) EKKO-BSART
    Regards,
    John.

  • How to find out the type of the value stored in a string variable?

    Hi,
    How do i find out the type of the value stored in a string variable?
    for example,
    I have a string variable str, in which the following type of values wil be stored
    1) Intger
    2) Long
    3) boolean
    4) Char
    Is there any method to find out the type of the value, anything like str.getType()?. Please kindly help me. Thanks in advance.

    Hi All, i'm sorry for the double posting, by mistake it occured.
    Thanks for your replies, i have a string variable str, in which the value is stored and i have another string variable type, in which the type of the value is stored.
    For example,
    String str = "15";
    String type = "Integer";
    Is there any way to verify whether the value stroed in str is of type stored in the variable 'type'. I want to write a method of type boolean, it will throw true of the value stored in str is of type 'type'. Thanks

  • How can i find the value category code in CJVC

    Hi Gurus
    how can i find the value category code in CJVC and which tables its stored.can any one tell me.please please

    Read TPIK3 in an internal table, then search COEP-KSTAR in this table, with KSTAR between TPIK3-KSTRF and TPIK3-KSTRT, and other keys like Controlling Area and application/component (eg "PS" in project-system as in CJVC or "PM" in Maintenance as in IW33, multiple application use this table). You can also use a FM like PS_FIND_ACPOS_FOR_KSTAR.
    Regards,
    Raymond

  • Where i can find the value categry code and element in cjvc

    hi gurus
    where i can find the value categry code and element in cjvc .in which table these fields are stored.could anyone tell me relation.
    Thanks & Regards
    Sandya

    not answer

  • Where can I find the value of "_kks_use_mutex_pin"??

    Hi, all.
    Where can I find the value of "_kks_use_mutex_pin"??
    What dictionary for "_**" parameter??
    Thanks and Regards.

    Hi,
    To find the value for a hidden parameter you must look in a hidden place:
    SQL> select
      2    x.ksppinm name,
      3    y.ksppstvl value
      4  from
      5    sys.x$ksppi x,
      6    sys.x$ksppcv y
      7  where
      8    x.inst_id=sys_context('userenv', 'instance') and
      9    y.inst_id=sys_context('userenv', 'instance') and
    10    x.indx=y.indx AND
    11    x.ksppinm = '_kks_use_mutex_pin';
    NAME                                                                             VALUE
    kksuse_mutex_pin                                                               FALSE
    SQL> show user
    USER is "SYS"
    SQL>Only SYS can see these special views. However, this does beg the question why do you want to see the value of this parameter? Attempting to change this value without official Oracle support is Not A Good Idea and can leave your database unsupported.
    HTH
    Chris
    Message was edited by:
    Chris Poole (because I can't spel)

  • How to find the value of a variable in other program

    How to find the value of a variable in other program say I am in a FM and this FM is being called in from other program and I want to know some of the variable details of the program from the FM itself. Imagine if this is a txn. and I need to know the details from some of the programs while executing the same transaction
    Regards
    Vin

    Hi Vinayak,
         you will be having your first program values in internal table or some variables,
        when you are calling the second program you wii use like this,
        SUBMIT <Second Program Name> USING SELECTION-SCREEN '1000'
                           WITH s_emp(second program select-options)   IN t_emp(first program variables)
                           WITH p_chk   EQ t_chk
                           WITH p_r1    EQ t_r1
                           WITH p_month EQ t_month
                           WITH s_cust1 IN t_cust1
                           WITH p_r2    EQ t_r2
                           WITH s_cust2 IN t_cust2
                           WITH s_week  IN t_week
                           AND RETURN.
    you have pas like this to get your first program details.

  • I need to add the values stored in the session object into the html textbox

    Dear Sir,
    i have been trying to create an edit employee details page
    What i have done till now is as follow:
    1. Got employee id from HTML page.
    2. Compared it with the id stored in the database.
    3. If the id is correct then pulled the record of the corresponding employee and stored it in the session object.
    4. Dispatched the session values to another servlet EditEmpDetails2.java
    what i need to do now
    5. Now i need to set the session values in the text field of the html form
    6. I also need to be able to edit those vales and store the edited values in the database.
    Please help me as i have tried doing it for 1 week without any clues
    i have tried to create a html page which is something like this:
    <html>
    <head>
    <title>Edit Employee Details Page</title>
    <body BGCOLOR="red" text="black">
    <h1 ><font color="black">Edit Employee Details Page</font></h1>
    <form action = "EditEmpDetails" method="Get">
    <table width="50% align="center"
    <tr><td>Employee ID: </td>
    <td><INPUT TYPE="TEXT" name="employeeid"<br></td></tr>
    <tr><td><center><input type="submit" value="submit"></center></td></tr>
    <tr><td><center><input type="reset" value="reset" ></center></td></tr>
    </table>
    </form>
    </body>
    </html>
    design of my servlet EditEmpDetails.java
    public void EditEmpDetails1 extends HttpServlet
    public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
    PrintWriter out = response.getWriter();
    response.setContentType("text/html");
    HttpSession session = request.getSession();
    String employeeid;
    String X = request.getParameter("employeeid");
    System.out.println("Employee iD:" + X);
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:murphy");
    String query = "Select * from users where employeeid=?";
    PreparedStatement stat = con.prepareStatement(query);
    System.out.println(stat);
    stat.setString(1,X);
    ResultSet rs = stat.executeQuery();
    while(rs.next())
    String Z = rs.getString(password);
    if(Z.equals(X))
    String A = rs.getString(1);
    session.setAttribute("employeeid", A);
    String B = rs.getString(2);
    session.setAttribute("firstname", B);
    String C = rs.getString(3);
    session.setAttribute("lastname", C);
    String D = rs.getString(4);
    session.setAttribute("gender", D);
    String E = rs.getString(5);
    session.setAttribute("dateofbirth", E);
    String F = rs.getString(6);
    session.setAttribute("address", F);
    String G = rs.getString(7);
    session.setAttribute("postalcode", G);
    String H = rs.getString(8);
    session.setAttribute("phone", H);
    String I = rs.getString(9);
    session.setAttribute("mobile", I);
    String J = rs.getString(10);
    String url = "/EditEmpDetao;s.java";
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url)
    dispatcher.forward(request,response);
    catch (Exception e)
    system.out.println(e)
    I do not know how to put the values stored in the session object into the html text box

    3. If the id is correct then pulled the record of the corresponding employee and stored it in the session object.do you really need to store this in session object?
    5. Now i need to set the session values in the text field of the html form which form? in a new html/jsp page? i suggest go for a JSP
    In your JSP page use JSP expression tags to put the session attributes.
    it's something like : <input type='text' name='employeeid' value='<%= session.getAttribute("employeeid") %>' >and you need to generateanother servlet for saving the details/modifications to the database.
    I think i m clear enough.
    if you need more clarifications. just try it and then post your problem.
    Diablo

  • How can i get the value stored in the session object using its sessionid

    how can i get the value stored in the session object using its sessionid by running stand alone java application

    myforum wrote:
    how can i get the value stored in the session object using its sessionid by running stand alone java applicationThis does not seem to make sense! You need at least to give a lot more detail of what you are doing.

  • How to compare the values stored in the list

    Hi,
    I am having the requirement that i want to compare the values stored in the list.How to store the values in the list and compare the list values stored inside it.
    Regards,
    Ahamad

    http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html#sort(java.util.List)
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collections.html#sort(java.util.List,%20java.util.Comparator)
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/Comparator.html
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Comparable.html

  • HT202359 Is there a way to find the value of an unused itunes card without scratching the PIN security strip?

    I have an itunes gift card that I want to check the value so I know which card I am giving to whom. Is there a I can find the value without removing the security strip?

    Hi,
    sorry, i got no idea how to get the datatype of a variant, but there are properties "ActualSize" and "Type" of the ADO Field-Object. In case of an empty field the ActualSize is zero. Maybe you can use that. See VI below.
    best regards
    chris
    Best regards
    chris
    CL(A)Dly bending G-Force with LabVIEW
    famous last words: "oh my god, it is full of stars!"
    Attachments:
    DB_Test.vi ‏67 KB

  • How do I find the value of GWYUID from within a form?

    Hi, can someone help me with the below?
    I'm trying to determine the value of the environment variable GWYUID from within a form so I can pass this value to the fnd_webfile.get_url function at runtime to display the output of a concurrent program in a web browser.
    I've tried the below but this just brings back null. Any ideas on how to find the value at runtime in 11i?
    v_gwyuid varchar2(100) := name_in('$environments$.gwyuid');
    fnd_message.set_string('GWYUID:'||v_gwyuid);
    fnd_message.show;
    Thanks, Geoff

    wow, many, many, many.... and many thanks!
    Just add a tiny modify to check out the Batch_type
    doc_id = (select batch_id from gme_batch_header where batch_no='&batch_number' and batch_type = 0)
    Because the batch_no can be duplicated as we also create Batch and Filrm Planned Order.
    Many thanks for your support!
    P/S: Sorry for my terrible English :P

  • How do you find the value of an iMac

    Just curious how and where to find the value of my iMac 20 inch

    Welcome!
    Find your exact model from this list:
    http://www.everymac.com/systems/apple/imac/index-imac.html
    Then click its link. The full specifications have an estimated used price value near the bottom:
    There are a lot of 20-inch iMac variants, so you need to at minimum do "About this Mac" to see what it shows for processor speed and type to find your model on the index.
    The last update of estimated prices was done last August. Prices on that site tend to be at the top of the range.

  • How to find the value of STO

    hi SAP gurus,
    pls help me out.
    is there any T-code to find the values of STO made.

    Hi Gaurav
    PLease use the Tcode ME81
    Regards
    Aasif

  • Table name where all CCMS values stored

    Hi,
    Can any one provide the table name where all CCMS values stored ( for all MTE classes) in the data base?
    Regards
    Soumitra

    Hi,
    it is not a single table where CCMS stores the alert data.
    it is comming from multiple functional modules like..
    SALM_MT_GET_TREE_AND_MTDATA,
    SALM_MT_TYPE_GET,
    SALM_VIRTUAL_MT_CREATE,
    SALM_MT_TREES_CONCATENATE,
    SALM_ALERTS_PROP_IN_VIRT_TREE,
    SALM_MONITOR_CREATE,
    SALM_MONITOR_DESTROY,
    SALM_MONITOR_LOAD,
    SALM_MT_ALERT_DATA_SHOW,
    SALM_MT_MARKED_INFO_GET,
    SALM_ALERT_SET_DONE,
    SALM_ERRONOUS_MT_NODE_CREATE,
    SALM_GET_TID_BY_NAME,
    SALM_MT_DETAIL_DATA_SHOW,
    SALM_MONITOR_NAME_GET,
    SALM_MT_TREE_DISPLAYCONFIG_GET,
    SALM_MT_ANALYSE_SHOW,
    SALM_MT_ANALYSE,
    SALM_MT_TREE_LEGEND_SHOW,
    SALM_RAISE_ALERT_STATE_CHANGE,
    SALM_MT_INVALID_ACTION_WARNING,
    SALM_MT_DESTROY,
    SALM_MT_RESET,
    SALM_MT_MARKING_EDITOR,
    SALM_MT_MONITORING_START,
    SALM_MONISET_READ_FROM_DB,
    SALM_MONISET_WRITE_TO_DB,
    SALM_MONISET_ATTRIBUTE_EDITOR,
    SALM_MONISET_DELETE_FROM_DB,
    SALM_GET_MT_TREE_MARKINGS,
    SALM_MT_DESTROY,
    SALM_MT_RESET,
    SALM_MT_MARKING_EDITOR,
    SALM_MT_MONITORING_START,
    SALM_MONISET_READ_FROM_DB,
    SALM_MONISET_WRITE_TO_DB,
    SALM_MONISET_ATTRIBUTE_EDITOR,
    SALM_MONISET_DELETE_FROM_DB,
    SALM_GET_MT_TREE_MARKINGS,
    SALM_MT_CLASSES_MARK,
    SALM_MT_CLASS_NAME_GET,
    SALM_MONITOR_COPY,
    SALM_MONISET_COPY,
    SALM_MT_SAMPLES_GRAPH_DISPLAY,
    SALM_MT_READ,
    SALM_MT_GET_AID_BY_TID,
    SALM_MT_DESCRIPTION_SHOW,
    SALM_MONIDEF_NODE_EDITOR,
    SALM_MONIDEF_EDITOR,
    SALM_RULE_RESULT_NODE_CREATE,
    SALM_MONITOR_TEMPLATE_GENERATE,
    SALM_MONITOR_TEMPL_NODE_CREATE,
    SALM_MONITOR_PRESENTATION_GEN,
    SALM_MONIDEF_NODE_CREATE,
    SALM_MONIDEF_EDITOR,
    SALM_RULE_RESULT_NODE_CREATE,
    SALM_MONITOR_TEMPLATE_GENERATE,
    SALM_MONITOR_TEMPL_NODE_CREATE,
    SALM_MONITOR_PRESENTATION_GEN,
    SALM_MONIDEF_NODE_CREATE,
    SALM_GET_MONIDEF_TREE_MARKINGS,
    SALM_MSC_TIME_INTERVAL_GET,
    SALM_TEST_VALUE_REPORT,
    SALM_MONISET_DIRECTORY_GET,
    SALM_MONITOR_DIRECTORY_GET,
    SALM_MONITOR_TEMPLATE_GET,
    SALM_MONITOR_PRESENTATION_GET,
    SALM_MONISET_DISPLAYCONFIG_GET,
    SALM_MT_ALERT_DATA_GET,
    SALM_MONITOR_DISPLAYCONFIG_GET,
    SALM_ABORTED_TOOL_STATUS_RESET,
    SALM_MONISET_DIR_LEGEND_SHOW,
    SALM_MT_PERF_HISTORY_DATA_GET,
    SALM_ALERT_DESCRIPTION_SHOW,
    SALM_MONIDEF_RULE_DESCR_EDITOR,
    SALM_RULE_PARAM_TYPE_HELP,
    SALM_RULE_PARAM_DOCU_HELP,
    SALM_RULE_PARAM_DESCR_CHECK,
    SALM_LOGIN_TO_SYSTEM_OF_MTE,
    SALM_MT_R3SYSTEM_EXPLORE,
    SALM_MONITOR_LOAD_IN_OWN_TASK,
    SALM_MT_ALERT_DATA_SHOW_GRID,
    SALM_MT_ALERT_DATA_BUILD_ALV,
    SALM_ALERT_TIME_INTERVAL_GET,
    SALM_TEST_COPY_MONISETS,
    SALM_MONIDEF_WRITE_TO_FILE,
    SALM_MONIDEF_READ_FROM_FILE,
    SALM_MONIDEF_SYNTAX_CHECK,
    SALM_MT_STATE_CHANGE,,
    SALM_LOAD_MON_FROM_ACTIVE_SET,
    SALM_MONIDEF_SYNTAX_CHECK,
    SALM_MT_STATE_CHANGE,
    SALM_LOAD_MON_FROM_ACTIVE_SET,
    SALM_GET_CURRENT_DB_FORMAT_VER,
    SALM_MONIDEFS_OF_MONISET_GET,
    SALM_GET_CURRENT_MONISET,
    SALM_SET_CURRENT_MONISET,
    SALM_MT_ASSIGN_ATTRIBUTE_GROUP,
    SALM_VOLATILE_RULE_PARAM_SET,
    SALM_VOLATILE_SYSIDLIST_SET,
    SALM_MT_CLASSES_MARK,
    SALM_MT_CLASS_NAME_GET,
    SALM_MONITOR_COPY,
    SALM_MONISET_COPY,
    SALM_MT_SAMPLES_GRAPH_DISPLAY,
    SALM_MT_READ,
    Edited by: Soumitra Roy on Oct 13, 2009 5:31 AM

Maybe you are looking for