Summing and Finding Maximum in 2d array

So I have an 2d array of numbers and I am trying to find the maximum sum of the rows and give back the row number. So far I can get the sum and the maximum number but I need to give back the row number of the maximum value.
public static void RowSumRow (int[][] table)
      static int sum[] = new int[5];
      int region=0;
      for (int row=0; row < table.length; row++)
            sum [row] = 0;
            for (int col=0; col < table[row].length; col++)
               sum [row] = sum [row] + table[row][col];     
      int max = myMethods.maximumSearch(sum);
      System.out.println("The maximal revenue is $" + max + " at region " + region);
    }myMethods.maximumSearch
public static int maximumSearch(int a[])
     int Max = a[0];
     for (int index=0; index < a.length; index++)
         if(Max < a[index])
          Max = a[index];
        return Max;
   }

this is correct right?
(the prarmeter rows is the rows that are to be tested)
public static void RowSumRow (int[][] table, int rows)
      int sum[] = new int[rows];
      int region=0;
      for (int row=0; row < table.length; row++)
            sum [row] = 0;
            for (int col=0; col < table[row].length; col++)
               sum [row] = sum [row] + table[row][col];     
      int max = myMethods.maximumSearch(sum);
      for(int x=0; x < sum.length; x++)
          if (max == sum[x])
            region = x-1;
      System.out.println("The maximal revenue is $" + sum[region] + " at region " + region);
    }This does what I want it to do right? Ive tested a few times and it is working, but is it logically correct?

Similar Messages

  • I've just updated OS to 10.10.1 and Finder keeps trying to open and then closes every 2 seconds with the message Finder is not Available. If Safari is opened full window it immediately closes and will only work with window smaller than maximum.

    I've just updated OS to 10.10.1 and Finder keeps trying to open and then closes every 2 seconds with the message Finder is not Available. If Safari is opened with the window full screen it immediately closes and will only work with window smaller than maximum. Driving me mad! Any help please!!

    Hi Linc
    Thank you for your response.
    I'm a bit of an amateur so I hope below is the information you've asked for:
    Step 1
    23/11/2014 09:19:14.007 ReportCrash[294]: Saved crash report for Finder[4349] version 10.10.1 (10.10.1) to /Users/AAAA/Library/Logs/DiagnosticReports/Finder_2014-11-23-091914_BBBB-MacBoo k-Pro-2.crash
    23/11/2014 09:19:14.008 ReportCrash[294]: Removing excessive log: file:///Users/AAAA/Library/Logs/DiagnosticReports/Finder_2014-11-23-091840_BBBB -MacBook-Pro-2.crash
    23/11/2014 09:19:14.000 kernel[0]: CODE SIGNING: cs_invalid_page(0x103809000): p=4357[Finder] final status 0x3000a00, denying page sending SIGKILL
    23/11/2014 09:19:14.000 kernel[0]: CODE SIGNING: process 4357[Finder]: rejecting invalid page at address 0x103809000 from offset 0x3f000 in file "" (cs_mtime:0.0 == mtime:0.0) (signed:0 validated:1 tainted:1 wpmapped:0 slid:0)
    23/11/2014 09:19:14.454 com.apple.xpc.launchd[1]: (com.apple.Finder[4357]) Binary is improperly signed.
    23/11/2014 09:19:14.454 com.apple.xpc.launchd[1]: (com.apple.Finder) Service only ran for 0 seconds. Pushing respawn out by 1 seconds.
    23/11/2014 09:19:15.584 Finder[4359]: assertion failed: 14B25: libxpc.dylib + 97940 [9437C02E-A07B-38C8-91CB-299FAA63083D]: 0x89
    23/11/2014 09:19:15.000 kernel[0]: CODE SIGNING: cs_invalid_page(0x10bfbf000): p=4359[Finder] final status 0x3000a00, denying page sending SIGKILL
    23/11/2014 09:19:15.000 kernel[0]: CODE SIGNING: process 4359[Finder]: rejecting invalid page at address 0x10bfbf000 from offset 0x3f000 in file "" (cs_mtime:0.0 == mtime:0.0) (signed:0 validated:1 tainted:1 wpmapped:0 slid:0)
    Step 2
    Process:               Finder [4626]
    Path: /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
    Identifier:            com.apple.finder
    Build Info: Finder_FE-932001003000000~1
    Responsible:           Finder [4626]
    PlugIn Path: /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
    PlugIn Identifier:       com.apple.finder
    -0 sec                         CODE SIGNING: cs_invalid_page(0x10c9a5000): p=4626[Finder] final status 0x3000a00, denying page sending SIGKILL
    -0 sec                         CODE SIGNING: process 4626[Finder]: rejecting invalid page at address 0x10c9a5000 from offset 0x3f000 in file "" (cs_mtime:0.0 == mtime:0.0) (signed:0 validated:1 tainted:1 wpmapped:0 slid:0)
    -2 sec                         CODE SIGNING: cs_invalid_page(0x10c5b3000): p=4624[Finder] final status 0x3000a00, denying page sending SIGKILL
    -2 sec                         CODE SIGNING: process 4624[Finder]: rejecting invalid page at address 0x10c5b3000 from offset 0x3f000 in file "" (cs_mtime:0.0 == mtime:0.0) (signed:0 validated:1 tainted:1 wpmapped:0 slid:0)
    -3 sec                         CODE SIGNING: cs_invalid_page(0x10f4bd000): p=4622[Finder] final status 0x3000a00, denying page sending SIGKILL
    -3 sec                         CODE SIGNING: process 4622[Finder]: rejecting invalid page at address 0x10f4bd000 from offset 0x3f000 in file "" (cs_mtime:0.0 == mtime:0.0) (signed:0 validated:1 tainted:1 wpmapped:0 slid:0)
    -5 sec                         CODE SIGNING: cs_invalid_page(0x105ecf000): p=4620[Finder] final status 0x3000a00, denying page sending SIGKILL
    -5 sec                         CODE SIGNING: process 4620[Finder]: rejecting invalid page at address 0x105ecf000 from offset 0x3f000 in file "" (cs_mtime:0.0 == mtime:0.0) (signed:0 validated:1 tainted:1 wpmapped:0 slid:0)
    -7 sec                         CODE SIGNING: cs_invalid_page(0x1012cd000): p=4617[Finder] final status 0x3000a00, denying page sending SIGKILL
    -7 sec                         CODE SIGNING: process 4617[Finder]: rejecting invalid page at address 0x1012cd000 from offset 0x3f000 in file "" (cs_mtime:0.0 == mtime:0.0) (signed:0 validated:1 tainted:1 wpmapped:0 slid:0)
    --> __TEXT 000000010c966000-000000010ce55000 [ 5052K] r-x/rwx SM=COW /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
        __DATA 000000010ce55000-000000010cf53000 [ 1016K] rw-/rwx SM=COW /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
    0   com.apple.finder                                 0x000000010c9a521f 0x10c966000 + 258591
    10  com.apple.finder                               0x000000010c9977b5 0x10c966000 + 202677
    11  com.apple.finder                               0x000000010c988154 0x10c966000 + 139604
    12  com.apple.finder                               0x000000010c987e15 0x10c966000 + 138773
    13  com.apple.finder                               0x000000010c987d35 0x10c966000 + 138549
    14  com.apple.finder                               0x000000010c987cfd 0x10c966000 + 138493
    28  com.apple.finder                               0x000000010c96b960 0x10c966000 + 22880
    1   com.apple.finder                                 0x000000010c98a69d 0x10c966000 + 149149
    2   com.apple.finder                                 0x000000010c98aba7 0x10c966000 + 150439
    3   com.apple.finder                                 0x000000010c9795d2 0x10c966000 + 79314
    4   com.apple.finder                                 0x000000010c98aa0b 0x10c966000 + 150027
    5   com.apple.finder                                 0x000000010c98a952 0x10c966000 + 149842
    6   com.apple.finder                                 0x000000010c98a78a 0x10c966000 + 149386
    7   com.apple.finder                                 0x000000010c979496 0x10c966000 + 78998
    8   com.apple.finder                                 0x000000010c98a548 0x10c966000 + 148808
    9   com.apple.finder                                 0x000000010c98a410 0x10c966000 + 148496
    10  com.apple.finder                               0x000000010c983df6 0x10c966000 + 122358
           0x10c966000 -        0x10ce54ffb  com.apple.finder (10.10.1 - 10.10.1) <33C3024A-4A16-3485-B2B1-89FA33B9558A> /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
    Many thanks
    David

  • Way to store and find the sum of prime numbers in a loop from 1 to an arbitrary N value

    i am intrested in a program in labview 8.5 to find out successive prime numbers between 1 to an arbitrary number N given as input and find out their sum as out put on front panel.
    Solved!
    Go to Solution.

    Is this a homework assignment?
    Spoiler (Highlight to read)
    Here's how I did it. 
    Here's how I did it. 
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

  • A Beginners Outcry: Homework of sum and Average

    Dear all,
    I am a java dummie. This is what happens intuitively in my mind. I need a program that runs to calculate the sum and average of either positive or negative inputed integers. The maximum input integers = 100. As defined, sn = sum of negative integers, sp = sum of positive, in = count of negative integers, ip = count of positive integers. If input integer = 0, the program comes to an end. If input integer is non zero, the outcomes would be sum of negative and sum of positive, average of negative and average of negative. I think I should use do-while statement, but..... Also, for the input, should I input a list of integers....Can someone show me the code plus some brief explanation that a beginner like me would be able to understand? Thanks.

    yawmark wrote:
    Can someone show me the code plus some brief explanation that a beginner like me would be able to understand?
    [So, You Need to Write a Program but Don't Know How to Start|http://home.earthlink.net/~patricia_shanahan/beginner.html].
    ~Ta. I just read through that article again, and again I find myself in awe of the sageness of such simple advise... I'm bookmarking it, to reread whenever I feel like tearing my hair out over a problem.
    Cheers. Keith.

  • FINDING MEDIAN FOR AN ARRAY OF INTS WITH EVEN NUMBER OF VALUES

    okie dokie fellas i know this has got to be easy but i hjave been sittin at my comp forever workin on projects that are due and my head isn't all there anymore...could someone please clue me in on how im supposed to write the logic to find the median of an array of integers if the array contains an even number of values...I know I have to average the 2 values on either side but i cant figure it out at all...sorry i know its dumb but thnaks to anyone who helps
    package pgm3deClercqMatt;
    * @author Owner
    * To change the template for this generated type comment go to
    * Window>Preferences>Java>Code Generation>Code and Comments
    import java.sql.*;
    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    import java.text.*;
    public class ExamStatistics
         public static void main(String[] args)
              DbConnection db = new DbConnection("pgm3");
              boolean moreRecords;
              String query = "SELECT * FROM pgm3Data ORDER BY ExamGrade";
              ResultSet rs = db.processQuery(query);
              int nbrGrades = 0;
              ResultSetMetaData rsmd = null;
              try
                   rsmd = rs.getMetaData();
              catch(SQLException sqlex)
                   JOptionPane.showMessageDialog(null, "SQLException getting ResultSet data or metadata");
                   System.exit(0);
              int s[] = new int[200];
              DecimalFormat decimal = new DecimalFormat("#,##0.00");
              int n = 0, aboveNinety = 0, numberAboveNinety = 0;
              double sum = 0, avgGrade = 0, medianGrade = 0;
              try
                   moreRecords = rs.next();
                   if(!moreRecords)
                        JOptionPane.showMessageDialog(null, "pgm3Data Result Set is Empty.");
                        System.exit(0);
                   while(moreRecords)
                        s[n] = rs.getInt(1);
                        n++;
                        moreRecords = rs.next();
                   }// end of while loop
                   System.out.println("n = " + n);
                   System.out.println("s[0]= " + s[0]);
                   System.out.println("s[n-1]= " + s[n-1]);
                   //FIND AVERAGE OF ARRAY
                   for(int j=0; j<n; ++j)
                        sum += s[j];
                        avgGrade = sum/n;
                   //FIND NUMBER OF GRADES ABOVE OR EQUAL TO 90
                   for(int j=0; j<n; ++j)
                        if(s[j]>=90)
                             numberAboveNinety++;
                   //FIND MEDIAN EXAM GRADE
                   for(int j=0; j<n ; ++j)
                        if(Math.abs(medianGrade - Math.floor(medianGrade))<1.e-10)
                              medianGrade = s[(j+1)/2];
                        else
                             medianGrade =    <HERE IS WHERE THE PROB IS
              }// end of try block
              catch(SQLException sqlex)
                   JOptionPane.showMessageDialog(null, " SQLException getting ResultSet data or metadata");
                   System.exit(0);
              String output = "";
              output = "Number of Exam Grades: " + n;
              output += "\nHighest Exam Grade: " + maxOfArray(s, n) + "\nLowest Exam Grade: " + minOfArray(s, n)
                        + "\nAverage Grade: " + decimal.format(avgGrade) + "\nNumber of exam grades above 90: "
                        + numberAboveNinety + "\nMedian Exam Grade: " + medianGrade;
              JOptionPane.showMessageDialog(null, output);
              System.exit(0);
         }// end of main
         static int maxOfArray(int z[], int n)
              int j, max = z[0];
              for(j=1; j<n; ++j)
                   if(z[j]>max)
                        max = z[j];     
              return max;
         static int minOfArray(int z[], int n)
              int j, min = z[0];
              for(j=1; j<n; ++j)
                   if(z[j]<min)
                        min = z[j];     
              return min;
    }// end of ExamStatistics
    class DbConnection
         //     class DbConnection creates and manages the db connection,
         //     processes queries, and returns result sets for processing
         private Connection connection = null;
         private String url="jdbc:odbc:";
         private Statement statement;
         private String username = "";
         private String password = "";
         private ResultSet rs;
         private int nbrResultSets = 0;
         //     Constructor Argument is the registered name of the database
         DbConnection(String dbName)
              try
              {// load driver to allow connection to database
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   connection = DriverManager.getConnection ((url+dbName), username, password );
              catch (ClassNotFoundException cnfex)
                   fatalError("ClassNotFoundException on connection attempt");
                   System.exit(0);
              catch (SQLException sqlex )
                   fatalError("SQLException -- Unable to Connect to db");
                   System.exit(0);
         } // end of constructor
         ResultSet processQuery(String query)
         //     process a single SQL query and return the resulting data set
              rs = null;
              try
                   statement = connection.createStatement();
                   rs = statement.executeQuery(query);
              catch (SQLException sqlex)
                   fatalError("SQLException on query or processing");
              return rs;
         void endConnection()
              try
                   connection.close();
              catch (SQLException e)
                   fatalError("SQLException on attempt to close connection");
         //     simple local fatal error handler
         private void fatalError(String msg)
              JOptionPane.showMessageDialog(null,msg);
              System.exit(0);
    } // end of class DbConnection

    sorry to anyone who thinks what i'm doing is a joke
    first of all i'm a student and secondly i'm taking
    java in a summer session so things don't get
    explained as well as they should. And how is this our problem?
    I'm doing the best
    i can. The for loop was because the array that I
    defined to hold 200 values was being filled by a
    database with a supposed unknown number of values but
    less than 200 so i waslooping through to get each
    value and put it in order and the conditional
    statement was supposed to test to see if the incoming
    median was an integer and was in the final write-up
    put into it's own boolean method returning false if
    there was no median and you needed to take the
    average of the next lowest and highest values. BThere's always a median. The definition I sent you tells you what it is.
    But
    thnak you very much to the people that actually help
    on here and don't try to bash people who have put
    effort into writing their code, however shitty it may
    look to them. You can't control what people say about your stuff. Everyone who criticizes your work isn't making a personal attack. They're telling you something that you should be learning from. Your problem is that you can't separate yourself from your work.
    No one knows absolutely everything and
    people who decide to talk down on others when they
    are using this forum as a last resort need to grow
    up.Grow up? That's what you need to do. If you think for a moment that you'll never be criticized once you leave that ivory tower you're sadly mistaken. You need to figure out how to separate yourself from your code.
    %

  • I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?

    I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?
    Attachments:
    try2.txt ‏2 KB
    read_array.vi ‏21 KB

    The problem is in the delimiters in your text file. By default, Read From Spreadsheet File.vi expects a tab delimited file. You can specify a delimiter (like a space), but Read From Spreadsheet File.vi has a problem with repeated delimiters: if you specify a single space as a delimiter and Read From Spreadsheet File.vi finds two spaces back-to-back, it stops reading that line. Your file (as I got it from your earlier post) is delimited by 4 spaces.
    Here are some of your choices to fix your problem.
    1. Change the source file to a tab delimited file. Your VI will then run as is.
    2. Change the source file to be delimited by a single space (rather than 4), then wire a string constant containing one space to the delimiter input of Read From Spreadsheet File.vi.
    3. Wire a string constant containing 4 spaces to the delimiter input of Read From Spreadsheet File.vi. Then your text file will run as is.
    Depending on where your text file comes from (see more comments below), I'd vote for choice 1: a tab delimited text file. It's the most common text output of spreadsheet programs.
    Comments for choices 1 and 2: Where does the text file come from? Is it automatically generated or manually generated? Will it be generated multiple times or just once? If it's manually generated or generated just once, you can use any text editor to change 4 spaces to a tab or to a single space. Note: if you want to change it to a tab delimited file, you can't enter a tab directly into a box in the search & replace dialog of many programs like notepad, but you can do a cut and paste. Before you start your search and replace (just in the text window of the editor), press tab. A tab character will be entered. Press Shift-LeftArrow (not Backspace) to highlight the tab character. Press Ctrl-X to cut the tab character. Start your search and replace (Ctrl-H in notepad in Windows 2000). Click into the Find What box. Enter four spaces. Click into the Replace With box. Press Ctrl-V to paste the tab character. And another thing: older versions of notepad don't have search and replace. Use any editor or word processor that does.

  • DIFFERENCE BETWEEN SUM AND COUNT IN SQL

    DIFFERENCE BETWEEN SUM AND COUNT IN SQL
    WHAT IS THE DIFFERENCE VERIFY IN DETAIL/

    21031980, I suggest you upgrade your computer sothat you can access google.
    lol.
    wtfpwnd.Google is also helpful for understanding the strange
    acronyms that show up around here lately (yes, I did
    find and understand this one). :-)Haha, sorry!
    It's the inner-gamer in me rearing its ugly head...
    :-)

  • How to debug and find the exact constraint violation error

    {122712 14:22:36:ErrorCode -1 with ErrorMessage as ORA-00001: unique constraint (OPS$CMS.PK_TB_ML_EXER_UPLOAD) violated has occured for [SSO16063259009], [CMSCOST_USER] pk_xop_subsales.pr_process_exer }
    {PROCEDURE pr_process_exer(
    p_voucher_num           tb_xop_order_manager_t.voucher_num%TYPE,
    p_status_type           tb_xop_order_manager_t.status_type%type,
    p_dest                    tb_xop_order_manager_t.dest%type,
    p_reference_key            tb_xop_order_manager_t.reference_key%type,
    p_seq_num                tb_xop_order_manager_t.seq_num%type,
    p_return_code            tb_xop_order_manager_t.return_code%type,
    p_reason_desc           tb_xop_order_manager_t.reason_desc%type,
    p_activity_qty            tb_xop_order_manager_t.activity_qty%type,
    p_leaves_qty            tb_xop_order_manager_t.leaves_qty%type,
    p_exec_price            tb_xop_order_manager_t.exec_price%type,
    p_current_status        tb_xop_order_manager_t.current_status%type,
    p_err_cur          OUT  ref_cursor)
    IS
    CURSOR get_order_dtls(v_voucher_num tb_xop_order_manager_t.voucher_num%type)
    IS
    SELECT *
    FROM   tb_xop_order_manager_t
    WHERE  voucher_num = v_voucher_num;
    CURSOR get_mail_cd(v_opt_num OPTIONEE.opt_num%TYPE) IS
          SELECT mail_cd, sp_mail_cd
          FROM XOP_OPTIONEE
          WHERE opt_num = v_opt_num;
    cursor get_opt_dtls(v_opt_num OPTIONEE.opt_num%TYPE) IS
    select
    SUBSTR(trim(O.name_first) || ' ' || trim(O.name_mi) || ' ' ||
              trim(O.name_last), 1, 35) p_name,
            SUBSTR(O.address1, 1, 35) opt_addr1,
              SUBSTR(O.address2, 1, 35) opt_addr2,
              SUBSTR(O.address3, 1, 35) opt_addr3,
              SUBSTR(O.address4, 1, 35) opt_addr4,
              SUBSTR(O.address5, 1, 35) opt_addr5,
              SUBSTR(O.address6, 1, 35) opt_addr6,
            SUBSTR(trim(O.city) || ' ' || trim(O.state) || ' ' ||
            trim(O.zip) || ' ' || trim(O.country), 1, 35) city_state_zip_country,
            trim(O.city) city,
            trim(O.state) state,
            trim(O.zip) zip,
            trim(O.country) country
    from  optionee o
    where o.opt_num = v_opt_num;
    --CQ:PCTUP00210726- Added wire instructions audit for deleted wire info.
    CURSOR c_wire_instruction (
          in_wire_seq_no           TB_XOP_WIRE_INSTRUCTIONS.wire_seq_no%TYPE ) IS
          SELECT ml_brok_acct_num,
                 ssn,
                 plan_num,
                 instr_type,
                 aba_routing_num,
                 swift_routing_code,
                 bank_name,
                 bank_acct_num,
                 name_on_account,
                 bank_addr_1,
                 bank_addr_2,
                 bank_addr_3,
                 city,
                 state,
                 country,
                 zip,
                 bank_ident_num,
                 addtl_info
            FROM TB_XOP_WIRE_INSTRUCTIONS
           WHERE wire_seq_no = in_wire_seq_no
           UNION
           SELECT ml_brok_acct_num,
                 ssn,
                 plan_num,
                 instr_type,
                 aba_routing_num,
                 swift_routing_code,
                 bank_name,
                 bank_acct_num,
                 name_on_account,
                 bank_addr_1,
                 bank_addr_2,
                 bank_addr_3,
                 city,
                 state,
                 country,
                 zip,
                 bank_ident_num,
                 addtl_info
            FROM TB_XOP_WIRE_INSTRUCTIONS_AUDIT
           WHERE wire_seq_no = in_wire_seq_no;
    CURSOR c_order_qty IS
    SELECT order_qty
    FROM tb_xop_order_manager
    WHERE voucher_num = p_voucher_num;
    v_order_qty     tb_xop_order_manager.order_qty%TYPE;
    v_wire_instruction             c_wire_instruction%ROWTYPE;
    v_order_dtls      get_order_dtls%rowtype;
    v_opt_dtls        get_opt_dtls%rowtype;
    v_settle_dt       tb_ml_exer_upload.settle_dt%type;
    v_cusip_num       corp.cusip_num%type;
    v_err_cd          number(12):=0;
    v_err_msg         varchar2(4000);
    v_compy_nme       tb_fc_Compy.compy_nme%type;
    v_ml_sec_num      tb_fc_compy.ml_sec_num%type;
    v_mail_cd         xop_optionee.mail_cd%type;
    v_count1            PLS_INTEGER := 0;
    v_sum_activity_qty  tb_xop_order_manager_t.activity_qty%TYPE;
    v_transact_no       PLS_INTEGER;
    v_ivr_plan_num      tb_fc_compy.ivr_plan_num%TYPE;
    wait_for_more       EXCEPTION;
    exceeds_order_qty   EXCEPTION;
    --Added for CQ# PCTUP00481233
    v_sub_totfee number;
    v_sub_fixedfee1 number;
    v_sub_fixedfee2 number;
    v_sub_fixedfee3 number;
    v_sub_secfee number;
    v_sub_feenum number;
    --Added for CQ# PCTUP00481233
    v_fixedfee1 tb_xop_order_manager_t.fixed_fee1%TYPE; --SPIF# 43161- variable to hold fixed fee1
    BEGIN
        OPEN c_order_qty;
        FETCH c_order_qty INTO v_order_qty;
        CLOSE c_order_qty;
        dbms.output.put_line('completed1');
        IF v_order_qty <> p_activity_qty THEN
          dbms.output.put_line('completed2');
            IF p_status_type = 'EO' AND v_order_qty < p_activity_qty THEN
                RAISE exceeds_order_qty;
                  dbms.output.put_line('completed3');
            ELSIF p_status_type = 'EO' AND v_order_qty > p_activity_qty THEN
                -- Partial Execution
                INSERT INTO tb_xop_hold_multi_orders
                    ( voucher_num
                    , reference_key
                    , seq_num
                    , return_code
                    , reason_desc
                    , status_type
                    , activity_qty
                    , leaves_qty
                    , exec_price
                    , current_status
                    , waiting
                    ,activ_dt )
                VALUES
                    ( p_voucher_num
                    , p_reference_key
                    , p_seq_num
                    , p_return_code
                    , p_reason_desc
                    , p_status_type
                    , p_activity_qty
                    , p_leaves_qty
                    , p_exec_price
                    , p_current_status
                    , 'Y'
                    ,SYSTIMESTAMP );
                      dbms.output.put_line('completed4');
            ELSE
                IF p_status_type = 'BE' THEN
                    SELECT COUNT(1) INTO v_count1
                    FROM tb_xop_hold_multi_orders
                    WHERE voucher_num = p_voucher_num;
                      dbms.output.put_line('completed5');
                    IF v_count1 > 0 THEN
                        INSERT INTO tb_xop_hold_multi_orders
                            ( voucher_num
                            , reference_key
                            , seq_num
                            , return_code
                            , reason_desc
                            , status_type
                            , activity_qty
                            , leaves_qty
                            , exec_price
                            , current_status
                            , waiting
                            ,activ_dt)
                        VALUES
                            ( p_voucher_num
                            , p_reference_key
                            , p_seq_num
                            , p_return_code
                            , p_reason_desc
                            , p_status_type
                            , (-1) * p_activity_qty
                            , p_leaves_qty
                            , p_exec_price
                            , p_current_status
                            , 'Y'
                            ,SYSTIMESTAMP );
                        UPDATE tb_xop_hold_multi_orders
                        SET waiting = 'Y'
                        WHERE voucher_num = p_voucher_num;
                          dbms.output.put_line('completed6');
                    END IF;
                END IF;
            END IF;
              dbms.output.put_line('completed7');
            SELECT SUM(NVL(activity_qty,0)) INTO v_sum_activity_qty
            FROM tb_xop_hold_multi_orders
            WHERE waiting = 'Y'
            AND voucher_num = p_voucher_num;
            IF v_sum_activity_qty > 0 THEN
                IF v_sum_activity_qty <> v_order_qty THEN
                    RAISE wait_for_more;
                ELSE
                    -- final order in the partial execution; complete the process
                    UPDATE tb_xop_hold_multi_orders
                    SET waiting = 'N'
                        , process_dt = SYSDATE
                    WHERE voucher_num = p_voucher_num;
                END IF;
            END IF;
        END IF;
        UPDATE tb_xop_order_manager_t
        SET activ_dt = TO_CHAR( SYSDATE, 'YYYY-MM-DD HH24:MI:SS' ) || '.000'
            , dest = p_dest
            , reference_key = p_reference_key
            , seq_num = p_seq_num
            , return_code = p_return_code
            , reason_desc = p_reason_desc
            , status_type = p_status_type
            , activity_qty = v_order_qty --p_activity_qty
            , leaves_qty = 0 --p_leaves_qty
            , exec_price = p_exec_price
        WHERE voucher_num = p_voucher_num;
        dbms.output.put_line('completed8');
         * SPIF# 43161- Update of current status to PO moved at the end, same as how PROD works.
    IF (p_status_type = 'EO') THEN
      BEGIN
        select cusip_num
          into   v_cusip_num
          from   corp;
      EXCEPTION
          WHEN NO_DATA_FOUND THEN
              SELECT cusip_num
                INTO v_cusip_num
                FROM tb_xop_espp_compy
               WHERE compy_acronym = replace(replace(user,'CMS'),'_USER');
          WHEN OTHERS THEN
              NULL;
      END;
       select compy_nme,ml_sec_num, ivr_plan_num
       into   v_compy_nme,v_ml_sec_num, v_ivr_plan_num
       from   tb_fc_compy
       where compy_acronym = replace(replace(user,'CMS'),'_USER')
       UNION ALL
       select compy_nme, je_ml_security_number, ivr_plan_num
       from tb_xop_espp_compy
       where compy_acronym = replace(replace(user,'CMS'),'_USER');
    --   where  ivr_plan_num = replace(substr(p_voucher_num,1,7),'SSO','XOP');
      open get_order_dtls(p_voucher_num);
      FETCH get_order_dtls INTO v_order_dtls;
       v_settle_dt := fn_xop_bankopen_bizday(TRUNC(v_order_dtls.exer_date + 1));
       v_settle_dt := fn_xop_bankopen_bizday(TRUNC(v_settle_dt + 1));
       v_settle_dt := fn_xop_bankopen_bizday(TRUNC(v_settle_dt + 1));
       FOR c_mail_cd IN get_mail_cd(v_order_dtls.opt_num)
       LOOP
         v_mail_cd := c_mail_cd.mail_cd;
         -- Do we need to get sp_mail_cd and overlay with the sp_mail_cd in order_manager_t???
       END LOOP;
       OPEN get_opt_dtls(v_order_dtls.opt_num);
       FETCH get_opt_dtls INTO v_opt_dtls;
       CLOSE get_opt_dtls;
      v_fixedfee1 := nvl(v_order_dtls.fixed_fee1, 0);
       * SPIF# 43161- atleast one handling fee per day of transaction
      v_fixedfee1 := pk_xop_enh_exerupdate.chrg_tranxfixed_fee(v_fixedfee1,
                                                               v_order_dtls.symbol,
                                                               v_order_dtls.corp_acronym,
                                                               v_order_dtls.opt_num);
      --Insert into tb_ml_exer_upload
      --Added for CQ# PCTUP00481233
       Pk_Xop_Transactmodel.GET_FEE(v_order_dtls.GROUP_ID,v_order_dtls.SVC_ID,'SQ',v_order_dtls.opts_exer,
                                    round(v_order_dtls.exec_price, 4),v_sub_totfee,v_sub_fixedfee2,v_sub_fixedfee1,
                                    v_sub_fixedfee3,v_sub_secfee,v_sub_feenum,lpad(v_order_dtls.ssn,9,0));
       v_order_dtls.sec_fee:=v_sub_secfee;
       UPDATE tb_xop_order_manager_t
        SET sec_fee=v_sub_secfee
        WHERE voucher_num = p_voucher_num;
        dbms.output.put_line('completed8');
      --- End CQ # PCTUP00481233
      INSERT INTO tb_ml_exer_upload
                            (exer_num,exer_seq,
                             exer_dt, written_flag, backout_flag, output_line,
                             je_flag, opts_exer,
                             tot_tax,shrs_sold,comm_value,tot_fee,
                             mkt_prc,exer_type, soc_sec,
                             name_first, name_mi,
                             name_last,check_addr_1,check_addr_2,check_addr_3,
                             check_addr_4,check_addr_5,city,state,zip,country,
                             city_state_zip_country,
                             p_name,opt_addr1,opt_addr2,opt_addr3,opt_addr4,
                             opt_addr5,opt_addr6,
                             settle_dt,send_to_citibank_flag,
                             dom_chek_distr,foreign_currency_code,
                             distribution_method,wire_seq_no,
                             cusip_num, ml_retail_account,multi_curr_handling_fee,
                             ml_sec_num, corp_name,upd_optionee_addr,
                             outbound_flag, -- make it N
                             corp_symbol,taxwire_approve, -- make it not applicaplabe
                             exersource,
                             mail_cd, sp_mail_cd,
                             backup_withholding,
                             user_id,
                             acct_num_othr)
       VALUES(v_order_dtls.exer_num,0,v_order_dtls.exer_date,'N','N',NULL,
    -- PG 12/12/05 Changed to populate the je_flag based on dom_chek_distr         'D',
    -- PG 12/16/05 JE should not be generated for international checks.. So 'Y' always
              'Y', --je_flag
              v_order_dtls.opts_exer,0,--total tax will be 0.
              v_order_dtls.opts_exer, --shrs_sold,
              v_order_dtls.comm_value,
              --SPIF# 43161- replaced nvl(v_order_dtls.fixed_fee1, 0) with v_fixedfee1
              v_fixedfee1 + nvl(v_order_dtls.fixed_fee3,0) + nvl(v_order_dtls.sec_fee,0), --v_order_dtls.fees_amt,
              round(v_order_dtls.exec_price, 4),v_order_dtls.exer_type,
              LPAD(v_order_dtls.ssn,9,'0'), --v_order_dtls.ssn, Modified by Suresh on 02/08/07 for SPIF # 37210
              v_order_dtls.name_first,v_order_dtls.name_mi,v_order_dtls.name_last,
              v_order_dtls.check_addr_1,v_order_dtls.check_addr_2,v_order_dtls.check_addr_3,
              v_order_dtls.check_addr_4,v_order_dtls.check_addr_5,nvl(v_order_dtls.city,v_opt_dtls.city),
              nvl(v_order_dtls.state,v_opt_dtls.state),nvl(v_order_dtls.zip,v_opt_dtls.zip),
              nvl(v_order_dtls.country,v_opt_dtls.country),
              SUBSTR(nvl(v_order_dtls.city||v_order_dtls.state||v_order_dtls.zip||v_order_dtls.country,
                  v_opt_dtls.city_state_zip_country),1,34), -- COLUMN LENGTH MAX IS 35
              v_opt_dtls.p_name,v_opt_dtls.opt_addr1,v_opt_dtls.opt_addr2,v_opt_dtls.opt_addr3,
              v_opt_dtls.opt_addr4,v_opt_dtls.opt_addr5,v_opt_dtls.opt_addr6,
              v_settle_dt,decode(v_order_dtls.distribution_method,'W','Y','D','Y','C','Y','D'),
              v_order_dtls.dom_chek_distr,v_order_dtls.foreign_currency_code,
              v_order_dtls.distribution_method,v_order_dtls.wire_seq_no,
              v_cusip_num,v_order_dtls.acct_num,v_order_dtls.multi_curr_handling_fee,
    --          nvl(fn_get_sec_num(replace(substr(p_voucher_num,1,7),'SSO','XOP'),v_order_dtls.symbol),v_ml_sec_num),
              nvl(fn_get_sec_num(v_ivr_plan_num, v_order_dtls.symbol),v_ml_sec_num),
              v_compy_nme,v_order_dtls.upd_optionee_addr,
              'N', --'N' is for outbound flag.
              v_order_dtls.symbol,'D', --'D' for taxwires disabled
              'S', -- 'S' for source being subsequent sale.
              v_mail_cd,  --need to get mail_Cd??
              v_order_dtls.sp_mail_cd,v_order_dtls.backup_withholding,
              user,v_order_dtls.acct_num_othr);
    IF (NVL(v_order_dtls.wire_seq_no,0) > 0) THEN
       OPEN c_wire_instruction(v_order_dtls.wire_seq_no);
       FETCH c_wire_instruction INTO v_wire_instruction;
       CLOSE c_wire_instruction;
      INSERT INTO TB_XOP_TRANSACT_WIRE_INSTR
                           (user_id, exer_num, wire_seq_no, ml_brok_acct_num, ssn,
                            plan_num, instr_type, aba_routing_num,
                            swift_routing_code, bank_name, bank_acct_num,
                            name_on_account, bank_addr_1, bank_addr_2, bank_addr_3,
                            city, state, country, zip, bank_ident_num, addtl_info )
                        VALUES
                           (USER,v_order_dtls.exer_num, v_order_dtls.wire_seq_no,
                            v_wire_instruction.ml_brok_acct_num, v_wire_instruction.ssn,
                            v_wire_instruction.plan_num, v_wire_instruction.instr_type, v_wire_instruction.aba_routing_num,
                            v_wire_instruction.swift_routing_code, v_wire_instruction.bank_name, v_wire_instruction.bank_acct_num,
                            v_wire_instruction.name_on_account, v_wire_instruction.bank_addr_1, v_wire_instruction.bank_addr_2,
                            v_wire_instruction.bank_addr_3, v_wire_instruction.city, v_wire_instruction.state, v_wire_instruction.country, v_wire_instruction.zip,
                             v_wire_instruction.bank_ident_num, v_wire_instruction.addtl_info);
            dbms.output.put_line('completed10');
    END IF;
    /* PG 01/05/06 Call the check conversion only for international checks and wires */
    IF v_order_dtls.dom_chek_distr = 'N' AND v_order_dtls.distribution_method IN ('W', 'D', 'C') THEN
        /* PG 12/20/05 To process subsequent sales with wire or foreign currency distribution */
         v_transact_no := 88;
         pk_xop_citibank_forex.pr_cashconversion_ins_request( v_order_dtls.acct_num
                                                              , LPAD(v_order_dtls.ssn,9,'0') --v_order_dtls.ssn, Modified by Suresh on 02/15/07 for SPIF # 37210
                                                              , v_order_dtls.distribution_method
                                                              , v_order_dtls.foreign_currency_code
                                                              , v_order_dtls.wire_seq_no
                                                              , ROUND((v_order_dtls.opts_exer * round(v_order_dtls.exec_price, 4)),2)
                                                                - ROUND(v_order_dtls.comm_value,2)
                                                                - ROUND(nvl(v_order_dtls.fixed_fee1,0) + nvl(v_order_dtls.fixed_fee3,0) + nvl(v_order_dtls.sec_fee,0),2)
                                                                - nvl(v_order_dtls.multi_curr_handling_fee,0)
                                                                - nvl(v_order_dtls.backup_withholding,0) -- net proceeds
                                                              , v_order_dtls.multi_curr_handling_fee --handling fee
                    --Modified by Bhaskar/Suresh on 03/02/2006    --, v_order_dtls.login_name
                                                              , CASE v_order_dtls.login_name WHEN 'CLIENT/' THEN v_order_dtls.login_name||'SSO' ELSE v_order_dtls.login_name||'/SSO' END
                                                              , v_transact_no -- transact_no as place holder for exer_type 88
                                                              , v_order_dtls.check_addr_1
                                                              , v_order_dtls.check_addr_2
                                                              , v_order_dtls.check_addr_3
                                                              , v_order_dtls.check_addr_4
                                                              , v_order_dtls.upd_optionee_addr
                                                              , v_order_dtls.city
                                                              , v_order_dtls.state
                                                              , v_order_dtls.zip
                                                              , v_order_dtls.country
                                                              , v_order_dtls.login_ipaddress
                                                              , v_order_dtls.fcnum
                                                              , v_order_dtls.opt_num
                                                              , v_settle_dt,
                                                              p_exer_num => v_order_dtls.exer_num
    END IF;
    COMMIT;
    close get_order_dtls;
    END IF;
      * SPIF# 43161- Update to current status into PO is moved to this part, same as PROD.
    UPDATE tb_xop_order_manager_t
    SET exec_dttime = decode(p_status_type,'EO',to_char(sysdate,'DD-MON-YYYY HH24:mi:ss'),null)
         , exer_date  = TRUNC(SYSDATE)
         , cancel_dttime = decode(p_status_type,'CX',to_char(sysdate,'DD-MON-YYYY HH24:mi:ss'),'UR',to_char(sysdate,'DD-MON-YYYY HH24:mi:ss'),null)
         , current_status = 'PO'
         , sum_status = decode(p_status_type,'EO','X','C')
         , sum_stat_dttime = SYSDATE
    WHERE voucher_num = p_voucher_num;
          v_err_cd := sqlcode;
          v_err_msg := sqlerrm;
          open p_err_cur for select v_err_cd err_code,v_err_msg err_msg from dual;
    EXCEPTION
            dbms.output.put_line('completed200');
    /* PG 02/10 handled 'partial fill order' exception */
      when wait_for_more then
          v_err_cd := 0;
          v_err_msg := 'ORA-0000: normal, successful completion';
          pr_xop_log_errors('Partially filled; Waiting for more - Activity qty:' || to_char(v_sum_activity_qty)|| ' pk_xop_subsales.pr_process_exer');
          open p_err_cur for select v_err_cd err_code,v_err_msg err_msg from dual;
      when exceeds_order_qty then
          v_err_cd := sqlcode;
          v_err_msg := sqlerrm;
          open p_err_cur for select v_err_cd err_code,v_err_msg err_msg from dual;
          pr_xop_log_errors('Activity quantity exceeded the Order_qty - Activity qty: ' || to_char(p_activity_qty) || ' pk_xop_subsales.pr_process_exer');
      when others then
          v_err_cd := sqlcode;
          v_err_msg := sqlerrm;
          open p_err_cur for select v_err_cd err_code,v_err_msg err_msg from dual;
          pr_xop_log_errors('ErrorCode '||SQLCODE||' with ErrorMessage as '||SQLERRM||' has occured for '||user||'pk_xop_subsales.pr_process_exer');
                dbms.output.put_line('completed125');
    END pr_process_exer;
    Hi friends, any1 help me out how to define the ref-cursor in declaration section, and how to find at what situation the constraint error occurred..

    956684 wrote:
    Hi,.
    Friends plz help me out ..how to debug and find the exact position of the constraint violation..thank you for the help..There isn't a way to trace it unless you have caught the exception raised.
    As a way to start the debug, you will have to monitor
    1. All DML's against the Table on which you have constraint. More specifically, the DML's that act on the column you have constraint on.
    2. Use Exception Handling, to log the Error and the data that causes the constraint to fail.
    3. Do not forget to monitor the Triggers, if they are used, that would write some data into the column you have constraint on.
    Or
    Another way to trace is:
    select *
      from user_source
    where lower(text) like '%your_table_name%';
    order by type, name, line;Look at the lines, exclude that are in Declaration or in SELECT statements and target the DML's.
    Looking at the un-formatted code you posted, this statement looks like a culprit.
    INSERT INTO tb_ml_exer_upload
    (exer_num,exer_seq,
    exer_dt, written_flag, backout_flag, output_line,
    je_flag, opts_exer,
    tot_tax,shrs_sold,comm_value,tot_fee,
    mkt_prc,exer_type, soc_sec,
    name_first, name_mi,
    name_last,check_addr_1,check_addr_2,check_addr_3,
    check_addr_4,check_addr_5,city,state,zip,country,
    city_state_zip_country,
    p_name,opt_addr1,opt_addr2,opt_addr3,opt_addr4,
    opt_addr5,opt_addr6,
    settle_dt,send_to_citibank_flag,
    dom_chek_distr,foreign_currency_code,
    distribution_method,wire_seq_no,
    cusip_num, ml_retail_account,multi_curr_handling_fee,
    ml_sec_num, corp_name,upd_optionee_addr,
    outbound_flag, -- make it N
    corp_symbol,taxwire_approve, -- make it not applicaplabe
    exersource,
    mail_cd, sp_mail_cd,
    backup_withholding,
    user_id,
    acct_num_othr)
    VALUES(v_order_dtls.exer_num,0,v_order_dtls.exer_date,'N','N',NULL,
    -- PG 12/12/05 Changed to populate the je_flag based on dom_chek_distr 'D',
    -- PG 12/16/05 JE should not be generated for international checks.. So 'Y' always
    'Y', --je_flag
    v_order_dtls.opts_exer,0,--total tax will be 0.
    v_order_dtls.opts_exer, --shrs_sold,
    v_order_dtls.comm_value,
    --SPIF# 43161- replaced nvl(v_order_dtls.fixed_fee1, 0) with v_fixedfee1
    v_fixedfee1 + nvl(v_order_dtls.fixed_fee3,0) + nvl(v_order_dtls.sec_fee,0), --v_order_dtls.fees_amt,
    round(v_order_dtls.exec_price, 4),v_order_dtls.exer_type,
    LPAD(v_order_dtls.ssn,9,'0'), --v_order_dtls.ssn, Modified by Suresh on 02/08/07 for SPIF # 37210
    v_order_dtls.name_first,v_order_dtls.name_mi,v_order_dtls.name_last,
    v_order_dtls.check_addr_1,v_order_dtls.check_addr_2,v_order_dtls.check_addr_3,
    v_order_dtls.check_addr_4,v_order_dtls.check_addr_5,nvl(v_order_dtls.city,v_opt_dtls.city),
    nvl(v_order_dtls.state,v_opt_dtls.state),nvl(v_order_dtls.zip,v_opt_dtls.zip),
    nvl(v_order_dtls.country,v_opt_dtls.country),
    SUBSTR(nvl(v_order_dtls.city||v_order_dtls.state||v_order_dtls.zip||v_order_dtls.country,
    v_opt_dtls.city_state_zip_country),1,34), -- COLUMN LENGTH MAX IS 35
    v_opt_dtls.p_name,v_opt_dtls.opt_addr1,v_opt_dtls.opt_addr2,v_opt_dtls.opt_addr3,
    v_opt_dtls.opt_addr4,v_opt_dtls.opt_addr5,v_opt_dtls.opt_addr6,
    v_settle_dt,decode(v_order_dtls.distribution_method,'W','Y','D','Y','C','Y','D'),
    v_order_dtls.dom_chek_distr,v_order_dtls.foreign_currency_code,
    v_order_dtls.distribution_method,v_order_dtls.wire_seq_no,
    v_cusip_num,v_order_dtls.acct_num,v_order_dtls.multi_curr_handling_fee,
    -- nvl(fn_get_sec_num(replace(substr(p_voucher_num,1,7),'SSO','XOP'),v_order_dtls.symbol),v_ml_sec_num),
    nvl(fn_get_sec_num(v_ivr_plan_num, v_order_dtls.symbol),v_ml_sec_num),
    v_compy_nme,v_order_dtls.upd_optionee_addr,
    'N', --'N' is for outbound flag.
    v_order_dtls.symbol,'D', --'D' for taxwires disabled
    'S', -- 'S' for source being subsequent sale.
    v_mail_cd, --need to get mail_Cd??
    v_order_dtls.sp_mail_cd,v_order_dtls.backup_withholding,
    user,v_order_dtls.acct_num_othr);What is the Table structure of tb_ml_exer_upload and what columns do you have constraints on?
    Which column of the table tb_ml_exer_upload is your Primary Key (because constraint name mentions pk_tb_ml_exer_upload)?
    Edited by: Purvesh K on Jan 4, 2013 12:57 PM

  • How do you get the percentage of one number compared to the sum of the total in an array in ipad numbers

    How do you get the percentage of one number compared to the sum of the total in an array in ipad numbers

    On the iPad my example looks like this:
    To fill the formula down you tap cell and then Fill:
    And drag the bottom part of the yellow rectangle down:
    Wayne's example would look similar.
    SG

  • Finding maximum Date in Cube

    Hi,
    How can I find the Maximum date from all the dates of a date characterstic which exists in CUBE Data.
    I want restrict a selection in my Query with this maximum Date. So how can i fetch that date into a variable?

    Hi
    You can call the function module RSDRI_INFOPROV_READ in your exit for the variable and read the dates and find the maximum. You have to pass the name of the info cube u want to read. However writing this code is slightly a tedious job. So think of any other way u can meet ur requirement.
    If you want to use the function module tell me i ll send u a piece of code which will give you an idea.
    Thanks
    Mansi

  • Sum and Average Group Wage instead of Details Wage

    I have a subreport where I have included all of our employment records and grouped it by employee ID. In the Group Footer, to show the latest employment record I used the Max(Start Date) and I have also placed the Hourly Wage field here which shows the appropriate Wage for the Max Date. But I can't seem to use the Sum or Average Summary because it Sums and Averages All Wages in the Details report vs. only the latest record.
    So, how do I Sum/Average the wages for only the last employment record Or how do I create the report to show only the Last Employment Record?
    I'm using Crystal XI. Any help will be greatly appreciated.
    Thanks

    Place the fields in group header instead of placing in details section using maximum() function. Now got to report>record sort expert>add start date field-->select descending order.
    Now the report shows latest date entries for each group.
    If you want to calcualte the sum then use mannual running totals like
    create a formula like
    @sum:
    whileprintingrecords;
    numbervar i;
    i:=i+{field}
    Now place this in group header and supress
    create another formula like
    @Total:
    whileprintingrecords;
    numbervar i;
    place this in report footer which gives grand total.
    Regards,
    Raghavendra

  • Read Text row by row, plot them and find the max of its Power spectrum

    Hi, everyone,
    I have to read data from a text file, plot as a time serie and find the frequency to its max power spectrum. I found a previous post related to my issue so I revised his example a little bit. But once I decide to store the data into an array, the Labview reported:' Error 1 occurred at Scan From String (arg 1)'. Can anyone help me out?
    Thanks in Advance!
    Gab
    Attachments:
    ReadXYZmine.vi ‏18 KB

    Again my attachment got missed out.
    - Partha
    LabVIEW - Wires that catch bugs!
    Attachments:
    ReadXYZmine_Trim Whitespaces.vi ‏19 KB

  • Calculating min and max value from number array

    I have array which is having return type Number.i want to calculate min and max value of this array..try to help asap..
    Thanks
    dhanu

    hi there,
    public class MinMax {
         int arr[]= { 27, 3, 42, 18, 243, -43, 6, -8 };
         int min, max;
         public MinMax() {
    // it's very bad way to do it.
    //          min=99999;
    //          max=-99999;
    // this must be as following
                    min = max = arr[0];
              search();
              System.out.println("The minimum value is: "+min);
              System.out.println("The maximum value is: "+max);
         private void search() {
    // and here we can search from <1> index instead of <0>
              for (int j=1; j<arr.length; j++) {
                   if (arr[j]<min) {
                        min=arr[j];
                   else if (arr[j]>max) {
                        max=arr[j];
         public static void main(String args[]) {
              new MinMax();
    there is a bug in the supplied code. Your homework is
    to figure out what it is without posting another
    message for help with your homework.well, i think it's a tragedy :(

  • Sum and average of a list of integers

    heya all
    im trying Implement a program to find the sum and average of a list of integers terminated by the data marker -999.
    import java.util.*;
    public class sumaverage
       public static void main(String[] args)
    int sum = 0;     // input the first number
           int num = kybd.nextInt(); // kybd is an instance of Scanner
           while ( num != -999 )    // while the end of data not found
                sum += num ;
                num = kybd.nextInt(); // input the next number
           System.out.println("the sum is " + sum );
    }}Currently im getting " cant find symbol" on lines 10 + 16 pointing at the k in kybd.nextInt(); , could anyone tell me whats wrong as im lost ?
    Thankyou

    thanks mate , i cant belive i missed that :S
    im now trying to add the adverage to the code
    ive done the following coding , can anyone confirm this is correct ? it all compiles fine ...
    import java.util.*;
    public class sumaverage
       public static void main(String[] args)
         Scanner kybd = new Scanner(System.in);
         int sum = 0;     // input the first number
         int n;
         double Adverage = 0;
           int num = kybd.nextInt(); // kybd is an instance of Scanner
           while ( num != -999 )    // while the end of data not found
                sum += num ;
             n = kybd.nextInt();
                sum += n;
             Adverage = sum/n;
                num = kybd.nextInt(); // input the next number
           System.out.println("the sum is " + sum );
           System.out.println("The adverage of the integers is " + Adverage);
    }}

  • Find Intersection of two array elements in Oracle 9i

    How to find intersection of two arrays in pl/sql for Oracle 9i.
    it is feasible in 11g using given code but this code is not working in 9i please help....
    DECLARE
    abc LIST := list(1,2,3,4);
    def LIST := list(4,5,6,7);
    BEGIN
    dbms_output.put_line(format_list(abc MULTISET EXCEPT def));
    END;
    Thanks in advance.... :)

    Argh. Never mind. My coordinates were reversed.
    People that made my data set specified the coordinates as lat/long and I didn't question it. I can now see that Oracle expects long/lat instead, so my example works now.

Maybe you are looking for

  • Problem with backing up to external hard drive and then " recovering " files, apps etc.

    Hi there, I hope you can help me please, I have messed some things up from not knowing what I was doing : ( and would like to fix them if possible. I will try to be brief and concise. Here goes.... 1. My 2006 iMac 4 running Leopard OSX was starting t

  • Releasing Purchase Requisition

    Hi All, Here is problem with workflow....when user release the purchase requisition, it takes aroud 12 hours for the requisition to go from the inbox, also when requisition gets deleted it stays in the inbox. Can you please suggest me some solution?

  • Need an autoclicker program

    i need an autoclicker program for mac, but i cant find 1. and i know automator does that, but i can't sit here to restart it everytime it messes up and stops. any ideas plz?

  • Bank satement while saving throwing error

    hi viewers, after uploading statement, while saving system is throwing following error Cannot post. Processing status not correct     Message no. FV010 Diagnosis     The processing status of the statement/list is 8. The system, however,     can post

  • 4g nano wont turn on and wont charge what do i do?

    my 4th generation ipod died one day, i went to charge it and the ipod did nothing when i connected it. i hooked it up to the computer and still nothing and the computer doesn't recognize it and acts as if nothing is connected. nothing i do is working