Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

The purpose of this assignment is to give you practice working with one dimensional arrays. It will also introduce you to one of the oldest mathematical algorithms in the world. Note: It's easy to find Java code for this algorithm on the Internet, but DON'T go looking for it. This is a simple algorithm. You are capable of implementing it yourself, and the purpose of the assignment is for you to do some programming. Feel free to look at the Wikipedia page on the Sieve of Eratosthenes, though.

Instructions:

1.  Write a program that will compute all of the prime numbers up to a specified value in a number of different ways.

  • Your program must have 3 command line arguments. The first gives that value that you want to generate primes to. The second gives the method that the program will use to generate the list of primes. The third argument, if present, tells the program to print out the list of primes, for debug purposes. For example, running the program as follows:

>Primes 100 1 p

should generate an array of numbers such that the elements with prime indices have value 1, and elements with composite indices have value 0. Since there is a 3rd command line argument, the program should print out the list of prime numbers.

2.        

  • The methods that you must implement are:

1. Trial division by the numbers up to n

2. Trial division by 2 and the odd numbers up to sqrt(n)

3. Trial division by the primes up to sqrt(n)

4. The sieve or Eratosthenes

Once it has finished, the program should also print out the amount of time that it took to run.

  • Run your program on different sized inputs for the different methods.
  • Write a 1 page report including a table or graph of the results.
  • Turn in your report, your code and class files to the D2L dropbox.

Optional: Optimize your sieve routine so that it uses an array of bits, and only stores the odd numbers in the array. See how high you can go with this optimized sieve. Write about it in your report.

Assignment checklist:

  • Write your program so that it works with command line arguments.
  • Write the 4 different prime finding modes.
  • Make sure the programs compile and run from the command line without modification.
  • Write a 1 page report summarizing the results of running your program in different modes, and for different list sizes.
  • Include your source, executable files and report in your turnin.
  • Zip all of your files in a SINGLE .zip file and turn it in to the D2L dropbox.

Java, Programming

  • Category:- Java
  • Reference No.:- M9523015

Have any Question?


Related Questions in Java

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As