Odd & even array

Hi, can someone please tell me why this is not working? I am supposed to have a user input numbers into an array. If the numbers are even they go into the even ArrayList and for odd, vice versa.public static void main(String[] args)
         int num,xy=0, MAX = 10;
         int [] numbers = new int [MAX];
         EasyReader console = new EasyReader();
         ArrayList evenNumbers = new ArrayList();
         ArrayList oddNumbers = new ArrayList();
         for (num=0; num<=MAX; num++)
                System.out.println("Please enter a number to put into the array: ");
              numbers[num]=console.readInt();
         for (int x=0; x<=MAX; x++)
              Integer some= new Integer(numbers[x]);
              if((numbers[num]%2)==0)
                   evenNumbers.add(new Integer(x));
              else
                   oddNumbers.add(new Integer(x));
         for (int i=0; i<numbers.length; i++)
              System.out.println("The array is:" +numbers);
     for (int i=0; i<oddNumbers.size(); i++)
          System.out.println("The odd arrayList is: "+oddNumbers.get(i));
     for (int i=0; i<evenNumbers.size(); i++)
          System.out.println("The even arrayList is: "+evenNumbers.get(i));
Thanks.

By "exception 11" I think you mean an ArrayIndexOutOfBoundsException.
Take a look at these lines:
int num, MAX = 10;
int [] numbers = new int [MAX];
for (num=0; num<=MAX; num++) {
    numbers[num]=...
}If array numbers has 10 elements they are stored in numbers[0] to numbers[9] -- there is no numbers[MAX]. So loops that iterate over arrays should be written:
for (int num=0; num<numbers.length; num++) {You did that further down in the code, too.
something seems off???

Similar Messages

  • Can pages be rearranged/merged automatically to restore odd even sequence after one-sided scans of double sided documents

    I would like to scan into pdf format some documents that are deteriorating badly.  These documents are printed on both sides and there are lots of them.  The stack of documents can be placed in a regular feeder scanner but only one side of the documents will get scanned at one time.  I could then turn the stack upside down and scan the other side.  But that would leave me with a grouping of the odd pages pages of the documents as pdf, and a grouping of the even pages.  How could I then rearrange/merge the pages so they appear as a normal sequence of odd-even in the pdf? Thanks.

    Hey all:
    Thanks for the positive feedback. I found myself needing to do some collating and reversing again, and discovered that the script didn't show up in Acrobat 9. So I updated the script, and moved the menu item into the "Document" menu.
    Unfortunately I can't figure out how to attach the updated script in the new form editor, so I'll inline it. Copy the following script into a file and install it into your Javascripts folder, as before.
    // Complements: Planet PDF (http://www.planetpdf.com/)
    // Modified by Jeff Baitis for Acrobat 9 compatibility
    // Improved Collate function with status bar.
    // Add a menu item to reverse all pages in the active document
    app.addMenuItem({ cName: "Reverse", cParent: "Document", cExec: "trustedReversePages();", cEnable: "event.rc = (event.target != null);", nPos: 0 });
    app.addMenuItem({ cName: "Collate", cParent: "Document", cExec: "trustedCollatePages();", cEnable: "event.rc = (event.target != null);", nPos: 0 });
    trustedReversePages = app.trustedFunction(function()
      app.beginPriv(); // Explicitly raise privileges
      var t = app.thermometer;
      t.duration = this.numPages;
      t.begin();
      for (i = this.numPages - 1; i >= 0; i--)
        t.value = (i-this.numPages)*-1;
        this.movePage(i);
        t.text = 'Moving page ' + (i + 1);
      t.end();
      app.endPriv();
    // Collating pages
      Title: Collate Document
      Purpose: User is prompted to select document to insert/collate.
      Author: Sean Stewart, ARTS PDF, www.artspdf.com
    trustedCollatePages = app.trustedFunction(function()
      app.beginPriv(); // Explicitly raise privileges
      // create an array to use as the rect parameter in the browse for field
      var arRect = new Array();
      arRect[0] = 0;
      arRect[1] = 0;
      arRect[2] = 0;
      arRect[3] = 0;
      // create a non-visible form field to use as a browse for field
      var f = this.addField("txtFilename", "text", this.numPages - 1, arRect);
      f.delay = true;
      f.fileSelect = true;
      f.delay = false;
      // user prompted to select file to collate the open document with
      app.alert("Select the PDF file to merge with")
      // open the browse for dialog
      f.browseForFileToSubmit();
      var evenDocPath = f.value;
      var q = this.numPages;
      var t = app.thermometer;
      t.duration = q;
      t.begin();
      // insert pages from selected document into open document
      for (var i = 0; i < q; i++) {
          var j = i*2;
          this.insertPages(j, evenDocPath, i);
          t.value = i;
          t.text = 'Inserting page ' + (i+1);
      t.end();
      // remove unused field
      this.removeField("txtFilename");
      app.endPriv();
    Have fun

  • How can I change the background color of odd/even rows in a panelCollection

    Hi everyone.
    I'm using a panelCollection and I need to change the backgroung color for odd/even rows in the table,
    how can I do this, using a stylesheet, is there a special selector or property for this?
    globalResultCollection (UIPanelCollection object) , is a collection of UITable elements, and it's working fine.
    I just want to change the defaul background color for rows.
    Thanks
    <af:panelCollection id="GLOBAL_RESULT_COLLECTION"
    binding="#{admin.view.globalResultCollection}"
    styleClass="globalResultCollectionRegion"
    clientComponent="true">
    <f:facet name="menus">
    <af:menu id="GLOBAL_OPERATION_MENU"
    binding="#{admin.view.globalOperationMenu}" />
    </f:facet>
    <f:facet name="toolbar">
    <af:toolbar inlineStyle="width:100%"
    binding="#{admin.view.globalOperationToolbar}"
    id="OPERATION_TOOLBAR"/>
    </f:facet>
    </af:panelCollection>

    Hi,
    use this:
    af|table::data-row af|column::data-cell { background-color: #CCCCFF; }
    af|table::data-row af|column::banded-data-cell { background-color: #FFCCCC; }
    Regards,
    s o v i e t

  • Printing only odd/even numbered pages does not work

    I've got following problem: Printing only odd/even numbered pages does not work. Not in Preview, nor Adobe Reader. I Don't know why. i'm using a hp Color LaserJet 2550L. I just worked fine, but I cannot remember the time this failing first occured. I really hope the problem will be solved quick and easy.
    Thanks so far
    Bastian.

    Mine does not work either. I have trashed prefs, rewrote permissions, ran Disk Utility from a separate HD, etc. and I cannot get this feature to work.
    I got 45 odd pages to print last night and now it won't print odd or even pages. I am reduced to printing every backside page one at a time. If I would have known about this problem before I could have saved myself an hour and just printed them all on single sided sheets. I tried to save paper and now I'm screwed (timewise)......
    Any other suggestions would be greatly appreciated.
    Thank You,
    Dave Buckley

  • Different headers & footers on odd & even pages in Pages 5 ?

    Hello all,
    I just upgraded to Pages 5 in Mavericks.
    How can I have different headers & footers on odd & even pages ?
    For example a header containing odd numbers on the right page and even numbers on the left page.
    I looked carfully in the menus & panels but di not found how to create document for two-sided printing
    I used this function many times in Pages 09 !
    Thanks for your help
    Francois

    There are no facing pages in Pages 5.
    Peter

  • Odd/Even pages with data from two tables

    Hi Forum,
    Can you please extend help/suggest with the following scenario:
    I have two data tables and one table records needs to be printed on odd pages (Front page) and the other table records need to be printed on even pages (Back page). I need alternating front and back pages based on data records in the tables. Also second table will be having lesser records when compared with first table.
    I'm able to get the alternating Odd/Even master pages. But the first table is being printed in both the odd/even pages first and then the second table is being printed in both the odd/even pages. How can I restrict the printing of the first table on odd page and second table on even page?
    Thanks for your help/suggestions.
    ~Madan

    You can play with pagination tab in your LCD tab, but I have never learnt enough to be able to use it effectively.
    If I were in your shoes, I would alter the DDIC structures in the backend so you will only display it in the form, without any suicidal actions through the pagination, scripting or similar stuff.
    How: If you need to alter pages, you can do that in your backend, right?
    Like you can have a structure page with attributes:
    - up/ front: data for the front page
    - down/back: data for the back page
    and you will alter the data in the table with this structure as a line in your ABAP program and will use to form to display the trnaformated data only.
    Well... I don´t tell it is clear/right/ proper solution and cannot tell if there are any obstacles which will not let you use this scenario in your case, but you could consider this as an option...
    Regards Otto

  • Cannot Enable Odd/Even Printing

    Hi,
    I am attempting to print double sided on my p1102w by first printing all the odd-numbered pages of my document, and then the even-numbered pages.
    However, under OS X Yosemite (10.10.3), there is no way to edit the default printing presets. I can view all the presets and see their settings, but there is no way to edit the values.
    There are buttons to Delete and Duplicate presets but these buttons are greyed out and inaccessible. Does anyone know how to enable the different presets? I realise the p1102w is a basic printer, but surely odd/even printing is a fairly basic requirement?
    It seems a pity that HP do not provide their own Mac driver for Yosemite but rely on the included Apple driver, which surely must be much more limited.
    Cheers, Steven
    This question was solved.
    View Solution.

    Hello Steven!
    Great to see that you were able to locate the expended settings and complete the required task!!
    To add, from the lowest menu (The one listed as Layout / the application name (e.g. Textedit) / Copies & Pages within MS Office appliations) you may select Manual Duplex for the printer, that will guide you to reload the other side easier.
    If there is no dialog shown to reload a page simply load the printed side faced down into the input tray, then open and close the top cartridge access door to resume the manual duplex job.
    Regards,
    Shlomi
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • Odd/even, normal/reverse

    Why does Mac OS X printing dialogue have two separate screens for choosing options such as odd/even pages and normal/reverse order? These options are under "Copies and Pages" and under "Paper Handling". Which one takes precedent if something different is chosen on either screen?
    Kenton

    Kenton and Heike Eidse wrote:
    In "Copies and Pages", you can choose odd/even and reverse/normal. The problem is that in "Paper Handling", you can also choose odd/even and reverse/normal. So, the problem comes when I can choose to print odd pages in a normal order in the "copies and pages" section, and I can choose exactly the opposite, even pages and reverse order in the the "paper handling" section, all for the same print job. Which one will take precendent. One will have to override the other. I find it ridiculous that they double up like that.
    In general, where the options appear in the main print window with Copies & Pages showing, I would tend to use those options rather than the the ones under Paper Handling. The reason I would make that choice is that it is the application or the printer driver that is placing these choices in the main print window. I believe it is the application's responsibility to paginate the file and send it to the printing software. If the application, therefore, is asking me to make the choice, I would defer to the application. Whether this is correct behavior or not is debatable.
    I am not sure that there is one definitive answer as to whether the options in the main print window (Copies & Pages) will conflict with those under Paper Handling. It would depend on how the application paginates and sends the data to be printed. You can, of course, try various settings and click on Preview to see what is likely to happen.
    Matt

  • How to select odd/even rows from table....

    How to select odd/even rows from a table?
    Please help.
    Edited by: vaibhav on May 7, 2012 5:30 AM

    just don't expect the results to come out in the sequence odd, even, odd, even .....
    The answer you have marked correct needs two order by clauses to guarantee that.
    The inner select will return rows in a random order, potentially different each time you run it. The outer select may not return rows in the same order as the inner one.

  • [MSI Z97 Xpower AC] Confusion about odd/even Sata port number sides

    So newb here, performing his first computer build.
    Problem is that I don't see any numbers on my motherboard's sata ports.
    My manual is a little confusing, as the diagram and video shows the odd/even numbers on different sides.
    Due to the large number of drives & cable management concerns...I'd like to know the exact SATA port numbers before connecting & running computer.
    Can anyone tell me what side the odd/even Sata ports are located on?
    Are the odd numbers located on the motherboard side (while even are on case side)?
    Or, are the even numbers located on the motherboard side (while odd are on case side)?

    Thanks HenryW! 

  • Bates numbering odd even pages on right left sides of page

    with acrobat 9 pro is there a way to bates number files with numbers on the right side of the page with
    odd numbered pages and on the left side of the page for even numbered pages. when printed and bound into a book would like to have the bates on the outer edge of the pages.

    Thanks for the link. The following are a couple of quotes pulled from it:
    > The rules governing the use of zero appeared for the first time in Brahmagupta's book Brahmasputha Siddhanta, [19] written in 628.
    > The Indian numeral system (base 10) reached Europe in the 11th century, via the Iberian Peninsula through Spanish Muslims the Moors, together with knowledge of astronomy and instruments like the astrolabe, first imported by Gerbert of Aurillac. For this reason, the numerals came to be known in Europe as "Arabic numerals". The Italian mathematician Fibonacci or Leonardo of Pisa was instrumental in bringing the system into European mathematics in 1202
    I have read several articles and a book (The nothing that is, by Robart Kaplan) on the subject right around the turn of the millenium. I was flabbergasted by the arguments of those that wanted to jump start it a year early.
    In the book was a humourous quote of a 14th century European mathematician trying to explain what a zero was exactly and how it was used in simple arithmetic. It seems so obvious to us now that people have a hard time accepting that it wasn't always there.

  • Forcing pages to start from odd/even pages

    Hi,
    I have a book with this kind of documents in it:
    1) Cover, starting on an odd page.
    2) 2nd of Cover, starting on an even page.
    3) TOC, starting from an odd page.
    4) Main content, starting from an odd page.
    InDesign CS5 lets me define a general setting with Book panel > Book Page Starting Option. However, I don't see any setting to let me force each document/chapter to start from an odd or even page. Is there something like this somewhere?
    Without this kind of control, I must choose Continue on the next page as a general rule, with the risk of having some chapters start on the wrong page.
    Paolo

    Peter, I think this is the correct solution. Very easy to do, since the first paragraph of a page that must start on a particular side is usually a "special" paragraph (chapter title, legals, TOC, and so on).
    In case the page begins with an illustration, I can try with a hidden paragraph, or a paragraph containing text of the same color of the page.
    This is, however, something that InDesign could learn from FrameMaker, whose book documents can start each one from a separate side.
    Paolo

  • Printing error with odd/even pages

    Apologies if this is the wrong group, I looked for a more
    appropriate one
    but there doesn't seem to be one on this server. If there's a
    better place
    to ask this question, please let me know.
    Anyhow, I'm using Acrobat Reader, latest version (I updated
    off the Adobe
    site after first noticing the error just to be sure), and I'm
    having a
    couple of serious bugs when it comes to printing odd-only or
    even-only pages
    of a multi-page document. (I don't have one of those snazzy
    re-feeder
    printers that can do both sides, so if I want to print
    double-sided I have
    to do first one then the other.) At any rate, the problems
    are thus: on a
    document which has an odd number of pages, if I tell it to
    print all
    odd-numbered pages, it will invariably skip the first page.
    This one's not
    that serious, as I can just manually print page 1 after the
    fact. The
    really annoying problem occurs when I try to print the
    even-numbered pages.
    What happens in this case is it prints the first page (i.e.
    Page 2) *twice*.
    Once on the back of page 1 and again on the back of page 3.
    Needless to
    say, I now have to throw one of them out and redo it. (I've
    taken to
    printing the even-pages first now, so I can use the backside
    of that extra
    page 2 for scrap paper, whereas previously the extra sheet
    was basically
    useless as it was printed on both sides.) The bug does not
    seem to occur
    with documents that have an even number of pages. Only those
    with an odd
    number. Doesn't matter if I choose back-to-front or
    front-to-back. Doesn't
    matter what printer I use, I've tried 3 different ones (and
    made sure I had
    the latest drivers for each) and it happens in every case.
    I'm guessing
    that there's some confusion in the software as to the number
    of pages it's
    supposed to print. If a document has an odd number of pages,
    there's one
    more odd-numbered page than there are even-numbered pages,
    and it's getting
    it backwards, printing one more even-numbered page and one
    less odd-numbered
    page. Anyhow, it's really annoying, and a waste of paper and
    ink as well.
    Any ideas how to avoid this? (Seriously considering editing
    the documents
    and adding one blank page to the end of every document with
    an odd number,
    though it seems like that shouldn't be necessary...)

    Thank you for your response. These forums are specific to the
    Acrobat.com website and its set of hosted services, and do not
    cover the Acrobat family of desktop products. Please visit the
    following forums for any questions related to the Acrobat family of
    desktop products:
    http://www.adobeforums.com/cgi-bin/webx/.3bbeda8b/

  • How to rotate odd/even pages in opposite directions?

    I have a number of pdf documents with more than 1,500 pages. The left pages are rotated 90 degrees left and the right pages are rotated 90 degrees right. Using the Acrobat view and rotate feature, all pages within the document rotate. This makes 'the odd pages 'upright' but the even pages are then 'upside down'.
    What is an efficient method to rotate all these pages to an "upright" position that reads 'normally'?
    My goal is to covert these into searchable pdf documents using Acrobat Pro XI.

    FOLLOWUP: Thanks for the suggestions. Hopefully these answers will also help others in the future who face the same dilemma. I had 'jumped the gun' in the respect that I was new to Acrobat and had not discovered the Tools > Pages > Rotate method within the program. That worked perfect on another document that needed to have pages rotated in bulk. Also, I will now investigate the 'coded' method to learn a little more about the capabilities within Acrobat. Thanks again!

  • Odd/Even Fields - Removing Pixel Rows In PS

    This is hard to explain, but I have a challenging task here in PS. There has to be a way to do this!
    I have to make our video engineering dept. two separate files, one containing the EVEN rows of pixels, and one file with the ODD rows of pixels.
    BUT, I have to collapse the space between each pixel row, truncating the file height in half.
    I have produced two master PSD files now, 854x480 WVGA format. I created a grid of selections (saved as an alpha channel) for ODD rows and EVEN rows, and deleted the unnecessary rows. If you were to layer these two files together, the image would appear seamlessly.
    OK, fine. I almost have what I want, but I'm not done yet.
    What I have to do now is to remove the space between each pixel row (the transparent rows), truncating the file height to 240 pixels high.
    Yes, I know the final image will appear "odd", but this is for technology development purposes.
    Can anyone offer a procedure to remove the rows of transparent pixels, resulting in a shorter file height?
    I could post a PSD, I suppose, if someone wanted to see what I'm starting with.
    If each pixel row were on an individual layer, I could distribute the layers, one on top of the other. But moving each pixel row would mean 240 layers.
    There has to be another way.
    I'm thinking there might be a method of doing this in AE if I can't do this in PS.
    Thanks so much.

    Tom:
    I would process one file at a time, creating even and odd files, as opposed to breaking out two files using masks (as you seem to describe) and then processing those. I'm 95% sure you can action this to a batchable action (serial numbered even/odd files, not filename-prefix, if that makes sense). When creating the 239 dupes: dupe one set, then select both sets, dupe both, then select four, dupe those and so on. Do this in a blank action to make it easy to determine what you're duping. I created an action with 1024 sets of steps this way, which is more than enough to process both even/odd files, link everything, copy merged, save out, etc. If you're using CS3 the linking is much more simple: link layers 1 through 240 selecting all, vs: select layer 1, layer 2, layer 3, ...
    If you merge linked and copy to a new file called "odd," then when you batch the action you can create 001_odd.psd, 001_even.psd, 002_odd.psd, 002_even.psd, ... Get the receiver to sign off on receiving renamed files and then no handwork for you. Or bug the scripting folks in that forum and they might be able to help you with naming the resultant files based on original.
    J

Maybe you are looking for

  • Disappointed by the 928, Verizon, Nokia, and Microsoft

    I purchased the Nokia 928 shortly after the launch date because I wanted to like the new platform - I really did, and at $99 for a flagship smartphone, where could I go wrong? The answer? Nokia 928. I'm on my second as of now, the first kept freezing

  • Communicating USB using Labview VISA

    I have a USB RAW device that I am trying to communicate with using labview VISA. I have had success with setting up the driver and I am able to get information from the device such as serial number, etc. When I try to use the VISA read and write comm

  • Content Server Sharing

    Hello, I have installed Content Server 6.40 successfully on Win 2K3 Both URL are showing Running status, But repository shows defined status after some time if i unlock it again after 2-3 hr it will come to defined status. Also  category which i have

  • Embedded flash does not appear in Firefox

    I've embedded flash into a website, but only a white box appears. The embedded flash document appears in IE and Chrome. Here's my embed code: <pre><nowiki><div> <object style="width:420px;height:272px" > <param name="movie" value="http://static.issuu

  • Accessing Discoverer Viewer on a PDA

    Hi, Could anyone tellme if it would be possible to access discoverer viewer on a PDA running windows mobile 2003? We have a Portal running the discoverer portlets and when I click "Analyze" link the discoverer viewer errors with a java null pointer.