Moving through a vector

Help
I have retrieved the data below from a database and stored into a vector. (each row is stored into an array and in turn each row is stored into a vector). Now I have to show this data quarterly (add january, feb and mar into one quarter and so on.. I am having problems moving through this vector. Any help is appreciated.
Sue
Year Period Labor Force Employment Unemployment Unemployment Rate
1998 January 3,423 3,249 174 5.10
1998 February 3,379 3,199 180 5.30
1998 March 3,390 3,225 165 4.90
1998 April 3,398 3,244 154 4.50
1998 May 3,455 3,326 129 3.70
1998 June 3,564 3,403 161 4.50
1998 July 3,617 3,479 138 3.80
1998 August 3,629 3,489 140 3.90
1998 September 3,546 3,410 136 3.80
1998 October 3,574 3,409 165 4.60
1998 November 3,561 3,368 193 5.40
1998 December 3,476 3,298 178 5.10
1998 Annual Average 3,501 3,342 159 4.50

Here's is some pseudocode that might help. Of course, I did this quickly so, there might be a few syntax errors, etc. but you should be able to get the general idea. This might not be the most efficient way either, but it's the first thing I thought of.
    Vector data; //your vector of arrays
    Vector quarterData = new Vector(); //vector of vectors for storing data totals for all 4 quarters
    for (int q = 0 ; q < data.size(); q +=3 )
        int laborTotal = 0;
        int empTotal = 0;
        int unempTotal = 0;
        int unempRateTotal = 0;
        int unempRateAvg = 0;
        int startindex = q;
        int stopindex = q + 3;
        Vector thisQuarterData = new Vector(); //vector of totals for this quarter (will be added to Vector quarterData)
        //loop through each array for this quarter
        while ( startindex < stopindex )
            //access appropriate arrays in Vector data using the startindex as index
            //add values to quarterTotals
            //i.e. go through array and add to totals
            startindex++;
        unempRateAvg = unempRateTotal/3; //find quarter average
        //add totals to this quarters data vector
        thisQuarterData.add(laborTotal);
        thisQuarterData.add(empTotal);
        thisQuarterData.add(unempTotal);
        thisQuarterData.add(unempRateAvg);
        quarterData.add(thisQuarterData);
    }You will then have all of your quarterly data in the Vector quarterData which you can then loop through and output.
Hope this helps,
--Nicole                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Slow performance when moving bunch of vector shapes

    Hi there,
    Photoshop CS6 Beta is soo slow in comparison to Photoshop CS5 when moving lots of vector layers. Check the videoa below please:
    CS6 - http://screencast.com/t/wBOzhTySdSf
    CS5 - http://screencast.com/t/ab7BDbgNxUYe
    - GPU Settings Enabled in both
    - GeForce GTX 560, latest drivers
    - i7 3,4 GHz, 16GB RAM
    Why CS6 is so slow in this situation?
    EDIT:  I found the Problem comes form the Layer Palete. Take a look how changing the tabs form Layers to Channels affect the moving performance : http://screencast.com/t/Gi01o1GzFPzJ
    This have to be fixed, as in more complex files this will be huge problem..
    Regards,
    SK

    Hi,
    Nothing peculiar at all. Normal text laters.
    Each field have subgroups with info - http://screencast.com/t/ykon4QwdBxC Overall lots of layers there, but in CS5 no problem to move them.
    Still can't understand why I can move all of these better when layer palete is not displayed.
    Test file - https://docs.google.com/open?id=0B0phn6xiF-cobkc3cUViM0dSV3ktYk5Vbm5Bci1TUQ
    Please test it on CS5 (you will notice how smooth it is) and CS6 on both try to switch between layers palete and channels palete and try to move to see the difference. Move whole group named "Form",
    Please let me know if I can help with something else to define the problem.
    /I'm using Windows 7 x64, Photoshop CS6 beta x64/
    Thank you!
    Regards,
    SK
    Message was edited by: Simeon Kartov

  • Just recently my iPad started to get lazy on me I'll go on a website and it has trouble moving through the different applications within it. It has nothing to do with the wifi because it's doing it no matter what wifi it is using at the time.

    Just recently my iPad started to get lazy on me I'll go on a website and it has trouble moving through the different applications within it. It has nothing to do with the wifi because it's doing it no matter what wifi it is using at the time?

    Not sure what you are talking about.

  • Problem moving through CardLayout

    Hi,
    I have been unable to find any solid examples of CardLayout, so I have been using some code I found in this forum. I'm getting hung up on how to move forward or backwards through the cards. I know it is myCard.next but for some reason I'm getting hung up on which card I should be referencing and how to associate that card with the code. Perhaps someone could spot the error...
    Thanks,
    Steve
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class CardLayoutQuestionsv2 {
        public static void main(String[] arguments) {
            JFrame frame = new Interface();
            frame.show();
    class Interface extends JFrame {
         private dataPanel screenvar;
    //     private questionPaneOne abcdef;
         private JTextArea msgout;
         JPanel cardPane;
         Interface () {
              super("This is a JFrame");
            setSize(800, 400);  // width, height
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              // set-up card layout
              cardPane = new JPanel();     // for CardLayout
              CardLayout questions = new CardLayout();
              cardPane.setLayout(questions);
              cardPane.setBorder(BorderFactory.createCompoundBorder(
                                              BorderFactory.createMatteBorder(
                                                              1,1,2,2,Color.blue),
                                    BorderFactory.createEmptyBorder(5,5,5,5)));
              cardTestOnePane     cardOne = new cardTestOnePane();
              cardTestTwoPane     cardTwo = new cardTestTwoPane();
              cardPane.add("questionOne", cardOne);
              cardPane.add("questionTwo", cardTwo);
              // end set-up card layout
              // set-up main pane
              // declare components
              msgout = new JTextArea( 8, 40 );
              buttonPanel commandButtons = new buttonPanel(screenvar, msgout);
              JPanel pane = new JPanel();
              pane.setLayout(new GridLayout(2, 4, 5, 15));   // row, col, hgap, vgap
              pane.setBorder(BorderFactory.createEmptyBorder(30, 20, 10, 30)); //top, left, bottom, right
              pane.add(cardPane);
                 pane.add( new JScrollPane(msgout));
                 pane.add(commandButtons);
              msgout.append("Successful");
              setContentPane(pane);
              setVisible(true);
    class updateDataFields implements ActionListener {     // 400
         private dataPanel abc;
         private JTextArea msg;
         int count = 0;
         public updateDataFields(dataPanel xyz, JTextArea msgout) {     // 100
              abc = xyz;
              msg = msgout;
         }     // 100
         public void actionPerformed(ActionEvent evt) {     // 200
              String command = evt.getActionCommand();
                   if (command.equals("TestMe")){     // 300
                        msg.append("\nSuccessful");
                        btnNextPressed();
                   }     // 300
         }     // 200
         private void btnNextPressed() {     // 500
    // problem here
              cardPane.next(cardTwo);
              }     // 500
    }     // 400
    class buttonPanel extends JPanel {     // 200   Similar to ButtonPanel in Duke's Bakery
         public buttonPanel(dataPanel xyz, JTextArea msgout) {     // 100
              GridLayout actionGrid = new GridLayout(1, 1, 5, 15); // row, col, hgap, vgap
              setLayout(actionGrid);                    // different than panex.setLayout(xgrid);
              JButton buttonTest = new JButton("TestMe");
              buttonTest.setMnemonic('T');
              buttonTest.addActionListener( new updateDataFields( xyz, msgout ));
              add(buttonTest);
         }     // 100
    }     // 200
    class dataPanel extends JPanel {     // Similar to DataPanel in Duke's Bakery
         JLabel left1, left2, left3, right1, right2, right3;
         JTextField left01, left02, left03, right01, right02, right03;
        public dataPanel () {     // 1
              GridLayout grid = new GridLayout(3, 2, 5, 15); // row, col, hgap, vgap
              setLayout(grid);                    // different than panex.setLayout(xgrid);
              left1 = new JLabel("Left1");
              add(left1);
              left01 = new JTextField(0);
              add(left01);
              right1 = new JLabel("Right1");
              add(right1);
              right01 = new JTextField(0);
              add(right01);
    class cardTestOnePane extends JPanel {
         public cardTestOnePane() {
              GridLayout actionGrid1 = new GridLayout(2, 1, 5, 15); // row, col, hgap, vgap
              setLayout(actionGrid1);
              JLabel cardNumberOne = new JLabel("Card Number One");
              JLabel cardNumberTwo = new JLabel("Card Number Two");
              add(cardNumberOne);
              add(cardNumberTwo);
    class cardTestTwoPane extends JPanel {
         public cardTestTwoPane() {
              GridLayout actionGrid1 = new GridLayout(2, 1, 5, 15); // row, col, hgap, vgap
              setLayout(actionGrid1);
              JLabel cardNumberThree = new JLabel("Card Number Three");
              JLabel cardNumberFour = new JLabel("Card Number Four");
              add(cardNumberThree);
              add(cardNumberFour);
    }

    When importing files Lightroom states:
    The following files were not imported because they could not be read.
    IMG_5551.CR2
    When deleting files in Lightroom it states:
    The file named 'IMG_6191.jpg' could not be moved to the Trash folder
    When moving files Lightroom shows the following error:
    File could not be moved to the selected destination.
    EDIT: it is only happening in a single folder/location (with a lot of foto's and subfolders). The rest seems to be working correctly. Strange and irritating.

  • How can I loop through a Vector and compare

    I'm working on a school project that is a quiz server. Instructors could telnet into the app and create quizes and then users can take them. I have it so it can set up new quizes so far. Right now I'm working on it so the user can choose a quiz and take the test. Since it requires proper user handling I have it so I display the quiz ID and quiz Name. The user would need to enter the quiz ID to take it. I have it that as it displays the ID's it enters them into a Vector. Then I do a loop through all elements until I get one that equals the user selection. I'm having problems with it though. Here's some code:
    do
    quizCheck = false;
    for (int i=0;quizReference.size();i++)
    if (selectionInt==quizReference.elementAt(i))
    quizCheck=true;
    }while (quizCheck==false);
    It's giving me a Error #300:method==(int,java,lang.Object)not found in class testproject.TestProject on the if line. Is there a way to handle this scenario. Also is there a better way?

    Hi,
    elementAt(...) returns an Object - of what type is your selectionInt? - guess, it is a primitve int value, not an Object.
    You can find it easier - say, you have Integer values in that Vector - and selectionInt is an int value - now you can find it using
    int p = quizReference.indexOf(new Integer(selectionInt));
    p is either -1 (if not found) or the index of the first found element, with the same int value as selectionInt.
    Hope, this helps
    greetings Marsian

  • I downloaded firefox 3.6.13 and now when moving through sites it will unexpectedly not be able to load a page within a site. How do I fix this problem or revert to a previous version of firefox?

    The first few sessions Firefox seemed to be running great with improved speed. Yesterday, when I opened Firefox it could not open my homepage even though I checked for my internet connection ... my email service was working perfectly. I rebooted the computer and started Firefox and the homepage opened fine. I then visited an online newspaper site opened from my bookmarks. I was able to read one or two articles on different pages, but then when I selected another page in this site, Firefox was not able to access it (just keep trying to make a connection to the page). I restarted Firefox and went into an online banking site, again through a bookmark. Again after successfully accessing several different pages in the site Firefox was unable to connect to a requested page.
    Later in the day I restarted Firefox, entered the banking site and successfully completed my transaction. Visited several other sites and had no problems, then again Firefox could not load a page.
    This problem has continued today when looking at the online paper.
    I would like either a fix to this problem, or to return to the previous version of Firefox.

    Google Toolbar Options, in the Search tab, make sure that '''Enable the Google new tab page''' is check-marked. If that doesn't fix it for you, see this for support information about the Google Toolbar. <br />
    [http://www.google.com/support/toolbar/?hl=en] <br />
    Or visit the Google Toolbar forum. <br />
    [http://www.google.com/support/forum/p/Toolbar?hl=en]
    As far as your UserAgent showing Firefox 3.0.11, see this: <br />
    https://support.mozilla.com/en-US/kb/Websites+or+add-ons+incorrectly+report+incompatible+browser
    You might want to consider getting rid of that '''desktopsmiley''' program that has messed up your UserAgent, it is known as Malware.

  • Moving through each record

    How do I move through each record?
    I want to use some math function on one field and store the result in the other field one record at the time.
    How can I do it?

    How do I move through each record?
    I want to use some math function on one field and store the result in the other field one record at the time.
    How can I do it? You can read about Analytic Functions. It sounds like the one you want is either LAG or LEAD.
    LAG
    http://technet.oracle.com/docs/products/oracle9i/doc_library/901_doc/server.901/a90125/functions54.htm#83619
    LEAD
    http://technet.oracle.com/docs/products/oracle9i/doc_library/901_doc/server.901/a90125/functions58.htm#83836
    Different Function including Analytic
    http://technet.oracle.com/docs/products/oracle9i/doc_library/901_doc/server.901/a90125/functions2.htm#81312
    Good Luck,
    TwoPigs

  • Moving through a hyperlink

    I created a hyperlink on a slide, which took me to my website. Is it possible to go from the website to the next slide in the presentation, or do I need to return via the previous (hyperlinked) slide?
    PowermacG5   Mac OS X (10.4.2)  

    When you return from a hyperlink, you will be at the beginning of the slide you left on. For example, if you have
    Transition
    Build
    Build
    Build
    Link
    When you come back, you'll have to go through all of those again. The best thing to do is..
    Transition
    Build
    Build
    Build
    DISPLAY link
    Automatic transition to next slide that shows all builds already completed
    and then the actual link.
    This is only one example, but the main idea is the same. Make sure that when you come back from a hyperlink that you don't have to re-view a slide.

  • Moving through array backwards

    Hi guys,
    Im new to java and i have a small query. I have an array which i have found the maximum value of using the code below. I want to be able to move back through the array(the maximum value is at rightmost element).
    Any suggestions as the best way to do this(im a little confused!)
    thanks
    java.util.Arrays.sort(votesArray);
    int max = votesArray[votesArray.length-1];
    System.out.println("Elected =" + votesArray[votesArray.length-1]);

    This will do it:
    import java.util.Arrays;
    public class ReverseArrayTester
        public static void main(String [] args)
            if (args.length > 0)
                Arrays.sort(args);
                for (int i = 0; i < args.length; ++i)
                    System.out.println(args[args.length-1-i]);
    }MOD

  • Moving Through Messages

    Is there a way to move from one open message to another without closing each message I open?
    Here's my layout:
    Mail list has preview turned off
    Down & up arrow through list of messages
    Hit Enter key to open first message - window with message appears
    This is where I would like to move to the next message - using the keyboard - without closing the first message
    Any suggestions would be welcomed

    The challenge with using the Preview Pane is that as you progress down the list of messages to view them, each message gets marked as Read, even though you have simply passed over it to get to the one you want to read.
    The only way to avoid this is to use the mouse which nullifies the point I made in the first place - it's inefficient. It would be much more efficient to - as I've had in other Mac mail programs - have one window open above the list of messages, and a keyboard command that allowed you to populate that window with the previous or next message.

  • Moving through Windows

    hi, anyone know how I rotate through open windows on Safari; my fingers move to do Tab plus the button with the "cmd square-type logo thing" but this rotates through open programmes not windows.
    thanks

    Hi,
    You're close Try command+` (the backtick symbol, usually just above the tab key)

  • Spinning rainbow ball when moving through a file

    I'm on my macbook pro. Just got an Optoma projector. Just updated to Adobe Reader 8. When I am trying to move through a file window in Adobe, while my class is watching on the Optoma projector that is mirroring, I will click on the up or down arrows on the side of the window, and the computer will give me the spinning rainbow ball for several seconds before scrolling up or down. Is there some cache or file I need to be cleaning out to improve my computer's performance in Adobe Reader? Is it a problem with Adobe 8? or is the intervening variable that I have just started hooking up the computer to a projector? I have always had great answers posting and look forward to learning something else. Thanks.

    Hi
    Questions about Adobe Reader are best addressed in the Adobe Reader Forum, sponsored by Adobe. There, you'll find users who are knowledgeable about the product. Good Luck

  • Piece List and Object list are not moving through transports

    Hi All,
    I have created the Piece List and Object list for Language translation in Development system and saved them in transport.
    When i moved this in Quality system then nothing is showing there.
    I have checked the Log of transport movement,everything is showing OK there.
    Please suggest me the way to solve this issue.

    Hi
    let me explain in Points
    1
    error messages about logs not found during the transport.
    This is usually caused by incorrect maintenance of the setting for the transport directory. Check in particular the parameters DIR_TRANS and TRANSDIR by referring to the advice given in note 556734, section "What do I need to consider when setting up the transport?".
    2
    An import supposedly has an error, but cannot find an error in the log files.
    This is usually due to the order-independent logs. In the order-independent steps, DDIC objects of other requests may also be edited. For example, the request to adjust a table remains for so long in the internal transport tables and is therefore also processed during a subsequent transport until the adjustment was successfully completed. An error can then be displayed for the subsequent request although its objects were all imported without any errors. Explanatory notes for this are 413993, 512493, 407116 and 330378. After every import, the order-independent logs should therefore also be checked.
    If the system refers to canceled RDD* jobs, check the job log via SM37 and via ST22 the short dumps and via SM21 the syslog of the system.
    Hope all my inputs helps you
    santosh

  • HT5437 Menu button doesn't pull up menu....all I get is the slideshow moving through apple's photos...help!!.

    Menu button doesn't pull up menu....all I get is the slideshow of moving apple's included photos...HELP!!!

    Your Apple TV may have become paired with another remote. Hold the remote close to and pointed at the Apple TV, hold down the menu and Rewind buttons together for 6 seconds or until you see a broken chain icon on screen.

  • Firefox scrolls to the bottom of the page when I press the down arrow, instead of moving through the text.

    When I press the down arrow on Firefox, it scrolls to the bottom of the screen. I'm almost always just trying to move the vertical scroll bar down one or two picas (or however you measure it). This didn't used to happen until about 2009. Any suggested fixes?
    == This happened ==
    Every time Firefox opened
    == 2009

    Did you try hitting the '''F7''' key?

Maybe you are looking for

  • Serial number related sales orders???

    Hi everyone, i got this problem when i try to use serial number of an equipment to search all related sales orders. in our company it is defined that serial number would be created in the first sales order, when the customer purchase the configurable

  • Sound File into AIFF file, 8 Bits, 8 Khz.

    Write a small program that takes any sound file and converts it to: AIFF file, 8-bit, and 8-kHz, and a single channel. Explain each step plese.

  • How to copy from DVD

    Hi. I have a dvd which contain my friend's wedding movies. The problem is that everytime I played it on the DVD player, it gets stuck and said 'skipping damaged area'. But when I played on an actual player on the tv, everything's fine. Recently my fr

  • Using SWIFT adapter in XI

    Can any one please tell me how to install and use iway SWIFT adapter in XI. Thanks Abinash

  • What happened to the Insert Date menu item?

    In the Numbers 3.0 upgrade the Insert Date menu item is gone.  Where can I now find it?  Or is there now  shortcut? David