8 Replies Latest reply: Dec 1, 2007 11:28 PM by 807603 RSS

    Prime Number Programming

    807603
      Compute all primes less than N, and display the results
      step by step on the BlueJ terminal screen to show the working of your program. Upon
      completion, you are to summarize the computed results in an easy-to-read format.
      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, you should 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.

      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

      Must implement at least 3 classes for your program. Each of the classes should have
      clear and distinct responsibilities associated with it.
        • 1. Re: Prime Number Programming
          807603
          cross-posted:

          http://forum.java.sun.com/thread.jspa?messageID=9997903

          Now how do I tell the original poster tactfully that he's acting like a lazy good-for-nothing jerk by posting his homework assignment? I never was too good at tact here.
          • 2. Re: Prime Number Programming
            807603
            Tack isn't a real requirement in this case.
            • 3. Re: Prime Number Programming
              807603
              He created an account on these forums, then cut-and-pasted his homework assignment into a post. That's probably the most work he's put into anything his whole life.
              • 4. Re: Prime Number Programming
                807603
                can you help me please?
                I want to 3 class for the prime number.
                • 5. Re: Prime Number Programming
                  807603
                  jagkajiclub wrote:
                  can you help me please?
                  I want to 3 class for the prime number.
                  Most of us do not wish to help anyone who hasn't shown that they've first exerted major effort.

                  My suggestion to you: Show your code and ask specific questions about what in your code you don't understand. Otherwise you are just asking for someone to do your work for you, and here that just won't fly.
                  • 6. Re: Prime Number Programming
                    807603
                    jagkajiclub wrote:
                    can you help me please?
                    repeat after me: "give me t3h codez!"
                    • 7. Re: Prime Number Programming
                      807603
                      petes1234 wrote:
                      jagkajiclub wrote:
                      can you help me please?
                      I want to 3 class for the prime number.
                      Most of us do not wish to help anyone who hasn't shown that they've first exerted major effort.
                      It doesn't even have to be major effort.
                      My suggestion to you: Show your code and ask specific questions about what in your code you don't understand.
                      I'd call that "reasonable effort".
                      • 8. Re: Prime Number Programming
                        807603
                        The worst part of cross-posts is that your best answers get lost on the forgotten arm of the cross. I liked this answer much better than the one i gave on this thread, so I'll cross-answer it here:

                        Of course, E might have sent some of his students from Alexandria to Athens to ask the same question, and see if he got the same answer. I think he actually did something like that when he calculated the size of the earth.