How to keep value in arrayList and print into matrix form.

compute all primes less than N, and display the results
step by step .summarize the computed results in an easy-to-read format.(matrix)
The program starts by asking for an integer value N from the user. Print out the initial matrix
of numbers from 2 to N.
To find all primes less than N, begin by making a table of integers from 2 to N.
Find the smallest integer i, that is NOT prime and NOT crossed out. Mark i as a prime
number and cross out 2i, 3i, 4i, ?, ni N.
At this point, program should print the intermediate results in a matrix format, and pause
until any key is pressed before proceeding.clear screen every
time prior to printing the intermediate results (in the matrix format).
When i > N , the algorithm terminates. screen is cleared once again,
before the program prints the final results in the matrix format.
Following are the requirements for the matrix format:
- The matrix consists of 10 columns
- The number of rows varies, depending on the input N
- Initial matrix: The program prints an empty string in place of 1
- Intermediate matrix: The program prints values for all prime numbers and numbers
that are not crossed out. The program prints an empty string for each crossed-out
number.
Final matrix: The program prints only the prime numbers less than N
P.S I want to write at least 3 classes

This is my new first class but it have an error
import java.io.*;
import java.util.*;
public class ArrayListExample2 {
    public static void main(String[] args)throws IOException {
        ArrayListExample listExample = new ArrayListExample();
        listExample.doArrayListExample();
    public void doArrayListExample()throws IOException {
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         System.out.print("enter limit : ");
          int max=Integer.parseInt(br.readLine());
          System.out.println();
        int counter = 2;
        List listA = new ArrayList();// int list
        //List listB = new ArrayList(); //string list
        for (int i = 2; i <= max; i++) {
            System.out.print("\t" + i );
            listA.add(new Integer(i)); //???????2-max ??listA
          int count =0;
          BufferedReader en = new BufferedReader(new InputStreamReader(System.in));
          while(count<Math.sqrt(max))
                 // max may be number of input or size of array list
          //BufferedReader en = new BufferedReader(new InputStreamReader(System.in));
          System.out.println ("Please enter");
          en.readLine();// wait for enter
          listA.removeNotPrime();
          count++;
     public void removeNotPrime()// what parametor?Need?
          for (int i=0;i<Math.sqrt(max)))
               int prime = listA.get(i);
                    for (int j=i+1;i<=listA.size();j++)
                     int val = listA.get(j);
                    if (val%prime==0)
                    listA.remove(j);
This part for test
        for (int i = 0; i <= max; i++)  // printttttttttt
            //System.out.print("\t" + i );
               System.out.print("\t" + listA.get(i);
            // call class printMatrix;
}

Similar Messages

  • My macbook wont allow me to use the same hotmail address as i used on my other computers. How can I keep the same email and log into it on a macbook?

    my macbook wont allow me to use the same hotmail address as i used on my other computers. How can I keep the same email and log into it on a macbook?

    That indicates a hardware failure. Read here:
    http://support.apple.com/kb/ts1559
    If nothing works, you most likely have a hardware failure. Make an appointment at an Apple store to confirm.

  • In pages, when a create a document, potions of it, say several pages will be clumped together and it effects me editing their order.  It is like they are forever joined- How do I edit my document and print just one page or move just one page?

    In pages, when a create a document, potions of it, say several pages will be clumped together and it effects me editing their order.  It is like they are forever joined- How do I edit my document and print just one page or move just one page?

    May you open your eyes before creating a new thread ?
    Your question was already asked and answered today.
    https://discussions.apple.com/thread/3177074?tstart=0
    Yvan KOENIG (VALLAURIS, France) jeudi 14 juillet 2011 14:40:40
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8
    Please :
    Search for questions similar to your own
    before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • I'm trying to print from a full size 30x42 pdf of an AutoCAD file.  I only want to print an 8 1/2 x 11 portion, in scale.  How do I select the window and print in scale on my 8 1/2 x 11 printer?

    I'm trying to print from a full-size, 30x42 pdf of an AutoCAD file.  I only want to print an 8 1/2 x 11 portion, in scale.  How do I select the window and print in scale on my 8 1/2 x 11 printer (Brother MFC-9340CDW)?

    You might be better off contacting an AutoCAD support group.

  • How to set value for trim and bleed using jsx script?

    I have tried using bleedoffsetRect but somehow it is not working. Can anybody please help me on how to set value for trim and bleed using jsx script? Any example will be highly appreciated.
    Following is the code I am trying with:
    var _saveName = new File ( root_path +_strFileName+".pdf");
        var _saveOpts = new PDFSaveOptions();
        _saveOpts.printerResolution = 300; 
        var bleedarray = new Array();
         bleedarray[0] =9.00;
         bleedarray[1]=9.00;
         bleedarray[2]=9.00;
         bleedarray[3]=9.00;    
        _saveOpts.bleedOffsetRect = bleedarray;

    I would expect although I've not actually tried this for the bleed off set box to be larger than the artbaord and the first two values to be negative or 0…
    var bleedarray = new Array(-9,-9,artboard.width+9,artboard.height+9);
    Where 'artboard.width' & 'artboard.height' you will have calculated from your file. An Array(9,9,9,9); would not constitute any boxes bounds.

  • Does Anybody know how to keep the license files and Certificates in ISE-3315 During the upgrade.

    Hi,
    I have two ISE-3315 Appliances in production network.
    I need someone's help to explain, how to make the Secondary node as the primary admin note to reset-config.
    And then I would like to know how to keep the license files and Certificate during the Upgrade.
    Please help me to answer my questions.
    Thanks
    CSCO11872447

    The Cisco Identity Services Engine (ISE) provides distributed  deployment of runtime services with centralized configuration and  management. Multiple nodes can be deployed together in a distributed  fashion to support failover.
    If you register a  secondary Monitoring ISE node, it is recommended that you first back up  the primary Monitoring ISE node and then restore the data to the new  secondary Monitoring ISE node. This ensures that the history of the  primary Monitoring ISE node is in sync with the new secondary node as  new changes are replicated.
    Please  Check the below configuration guide for Secondary ISE- Nodes.
    http://www.cisco.com/en/US/docs/security/ise/1.0/user_guide/ise10_dis_deploy.pdf

  • How to keep both outlook calendar and icloud calendar?

    I understood that the iCloud calendar is used in outlook (and original outlook calendar is sent to deleted folder),
    can anyone figure out how to keep them both working and SYNCHRONIZED bothways?
    Thanks a lot,
                       Kasa

    I use a special Sync Tool which is very useful for syncing more than one calendar with outlook:
    iCal4OL
    See: http://ical.gutentag.ch/

  • How to keep the Sonogram settings and make them "Sticky"?

    I am a Forensic Audio Examiner and would love to use Soundtrack Pro. Does anyone know how to keep the Sonogram settings and make them "Sticky" so you don't have to reset it every time you open up the project?
    Also the Sonogram loses it's frequency range settings while changing the zoom.
    Where is the feedback link for this application?
    Thanks

    are you talking about the spectrum analysis?

  • How do I make my HP P2055dn printer into a wireless network printer for 5 computers

    How do I make my HP P2055dn printer into a wireless network printer for 5 computers? Windows versions on computers used are  XP,Vista & 7.
    Thanks
    Leon

    Unplug the USB cable from the printer.  Plug your printer into your wireless router with an Ethernet cable.
    Next, on each computer, get the latest software for your printer from the "Support & Drivers" link at the top of this page.  Install it and select "Network" installation when it asks.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • HT201365 How do I download Whatsaap, Facebook and Skype into my home screen. When I try it gives me an erros message saying that this is not available in a Panamanian store and I live in the US. HELP????

    How do I download Whatsaap, Facebook and Skype into my home screen. When I try it gives me an erros message saying that this is not available in a Panamanian store and I live in the US. HELP????

    Change your country on iPhone, iPad, or iPod touch
    Tap iTunes Store, App Store, or iBooks Store.
    At the bottom of the Featured page, tap Sign In.
    If you're already signed in, skip to step 5.
    Tap Use Existing Apple ID.
    Enter your Apple ID and password and tap OK.
    Tap your Apple ID.
    Tap View Apple ID or View Account.
    Tap Country/Region.
    Tap Change Country or Region.
    Tap the Store menu and tap your country.
    Tap Next.
    Review the Terms and Conditions and Apple Privacy Policy.
    Tap Agree if you agree to the terms and conditions.
    In the prompt that appears, tap Agree.
    Select a payment method and enter your payment information.
    Enter your billing address and tap Next.

  • How to convert non-fillable forms in words and PDF into fillable forms?

    Hai,
    How to convert non-fillable forms in words and PDF into fillable forms?

    Hi Mahalcs
    Please See the below link for reference : http://www.adobe.com/in/products/acrobat/convert-existing-forms-to-fillable-pdfs.html
    Also See , http://www.adobe.com/content/dam/Adobe/en/products/acrobat/pdfs/adobe-acrobat-xi-convert-f orms-into-fillable-pdf-tutorial_ue.pdf

  • "Missing parameter values."  --  Export and Print only...

    I have a web application and I am using CrystalReportViewer.  I am passing several parameters to Crystal using: 
    report.SetParameterValue(field.Name, Session[field.Name]);
    I have session variables which will hold parameters needed to pass into the report.  The session variables are populated from controls on my webpage after an onclick event.  This even not only populates session, but also passes parameters to the report with the following code: 
    ReportDocument report = new ReportDocument();
    Session["MapPathName"] = "./Reporting/CaseStudy.rpt";
    report.FileName = Server.MapPath(Session["MapPathName"].ToString());
    ParameterFields fields = new CrystalDecisions.Shared.ParameterFields();
    fields = report.ParameterFields;
    foreach (ParameterField field in fields)
          report.SetParameterValue(field.Name, Session[field.Name]);
    CrystalReportViewer1.ReportSource = report;
    This works great for reporting and is very extensible.  However, when clicking on the "Print" or "Export" buttons on the toolbar I get "Missing parameter values."  I attempted to export manually in code using the .ExportToStream function but I still get the error, "Missing parameter values." 
    I received this error also in Refresh, Search, and Navigate functions.  This was corrected by calling a function that supplies the above code block to these functions.  However, I do not see any events for controlling the Print nor the Export events. 
    QUESTION: How can I print or export a report when passing parameters using CrystalReportViewer?  Thanks in advance!
    P.S. - Crystal Reports XI Release 2
    Edited by: KyleSavant on Jun 18, 2009 5:42 PM

    There are no Export or Print events accessible for the viewer
    Since it sounds like you are creating the reportdocument object in your click event, the settings on this object become out of scope on successive postbacks executed by other events.
    to get around this without major changes, you can place your "report" object in session in this event and retrieve it from session on successive postbacks.  This should solve your problems around navigation, printing and exporting.  What you will need to do is check if the session object exists (usually in page_load or page_initialze) and if so, retrieve it from session and bind it to the viewer's reportsource.  If the session object does not exist, then do nothing (ie you have not clicked your button yet that retrieves the parameter values from session and loads the report).  Also, in your click event you can check if the report session object exists and if so, remove it so that it can be re-created with your new parameter values (ie i'm assuming the only time you want to set parameter values is in this event).
    Dan

  • Is there any tutorial on how to keep macbook pro clean and fully working?

    Hi everyone,
    I bought a macbook pro three days ago (and it works like a charm by the way). I'll be using this computer mainly for school work so I don't want to mess it up like I did on my iMac 2011. So what would you suggest to keep this computer clean and fully working (like a new one) for a long time since I plan to keep it at least 3-4 years? Would you recommend any cleaning software, or to manually clean the macbook once in a while? Basically, all I want to know is how to keep a healthy mac as long as possible!
    For the physical aspect of the mac I already have a sleeve for it so I don't think it's going to be an issue.
    Thank you!
    AteMyApple

    No maintence necessary, really - see Thomas Reed's article:
    The myth of the dirty Mac
    ...and...
    Mac Performance Guide
    ...both make good reading. DO NOT mess with any 'clean your mac' utilities - they're junk and may do more harm than good.
    Clinton

  • How do I edit a "fill and print form" using Acrobat XI?

    We recently upgraded to Adobe Acrobat Pro, version 11. We have some staff who previously created "fill and print" forms with Adobe Acrobat 10. However, now when they try to use version 11 to edit the form, they receive the following message: This form cannot be edited in Acrobat. Please use Adobe LiveCycle Designer to edit this form.
    If I remember correctly, version 10 (or some package suite) use to install LiveCycle along with version 10. This doesn't seem to be the case with version 11. So... How do we obtain LiveCycle Designer? Is it still available to install on a desktop or is it only available in the cloud?  Or, preferably, is there a way to edit the form using Acrobat Pro version 11?
    I don't work with Adobe forms myself, so any information you can provide will be extremely helpful. Thanks.

    LCD forms can only be edited in LCD. However, Adobe stopped distributing LCD together with Acrobat. You need to purchase it separately now, but if you had a previous license you can get it at a large discount, I think. Try the LCD forums for more info about that.

  • How do I edit a "fill and print form" using Acrobat Pro XI?

    We recently upgraded to Adobe Acrobat Pro, version 11. We have some staff who previously created "fill and print" forms with Adobe Acrobat 10. However, now when they try to use version 11 to edit the form, they receive the following message: This form cannot be edited in Acrobat. Please use Adobe LiveCycle Designer to edit this form.
    If I remember correctly, version 10 (or some package suite) use to install LiveCycle along with version 10. This doesn't seem to be the case with version 11. So... How do we obtain LiveCycle Designer? Is it still available to install on a desktop or is it only available in the cloud?  Or, preferably, is there a way to edit the form using Acrobat Pro version 11?
    I don't work with Adobe forms, so any information you can provide will be extremely helpful. Thanks.

    LCD forms can only be edited in LCD. However, Adobe stopped distributing LCD together with Acrobat. You need to purchase it separately now, but if you had a previous license you can get it at a large discount, I think. Try the LCD forums for more info about that.

Maybe you are looking for

  • Mail has missing plug-in

    In Safari 5.1 I removed the PDF from Quicktime Plug-In.  Now I am getting a message Mail that I am missing a plug-in when I attach a PDF file to an outgoing email.  Yet the PDF file does go out with the sent email. Any clues?  Have I somehow removed

  • Turning off onscreen display

    We are looking into purchasing an ATV for the workplace to show content we have created for our clients (we are a video post production house). I have one at my home that I am familiar with & have been experimenting for work purposes. When setting up

  • Can't update my Shuffle

    I'm having trouble with my Shuffle.. this started happening a few weeks ago. iTunes can't detect it. when i try opening it in My Computer, it freezes, and i can't get the latest iPod updater to work for it. it says "iPod Service Error" or something l

  • Can't reformat my DV5 it say BOOTMGR is missing pls help,,

    Reformat

  • Clone a Database

    Machine One: Oracle11g r2 on SUSE Linux 11 standalone server. Created a database db1 on a file system. Database files are backed up in FULL to the hard drive such as /u01/oradata/backup. Machine Two: Oracle 11g r2 on SUSE Linux 11 standalone server.