java stacks queues

AcademicWritersDen.com boasts a team of highly skilled and experienced writers who specialize in various academic fields. The company carefully selects its writers through a rigorous screening process to ensure that they possess the necessary qualifications and expertise. Whether it’s an essay, research paper, or any other homework assignment, students can rely on AcademicWritersDen.com to connect them with professionals who have an in-depth understanding of the subject matter. This ensures that the work delivered is of high quality and meets the academic standards set by educational institutions.

Minimal Submitted Files

You are required, but not limited, to turn in the following source files:

Assignment11.java (You do not need to modify this file.)
PrimeComputing.java — to be completed.

Requirements to get full credits in Documentation

  • The assignment number, your name, StudentID, Lecture number, and a description of each class/file need to be included at the top of each file/class (in this assignment, you might have only one file/class, but in future there will be more than one file.)
  • A description of each method is also needed.
  • Some additional comments inside of methods (especially for a “main” method) to explain code that are hard to follow should be written. You can look at Java programs in the text book to see how comments are added to programs.

New Skills to be Applied

In addition to what has been covered in previous assignments, the use of the following items, discussed in class, will probably be needed:

Queues

Program Description

Class Diagram:

Assignment #11 will be the construction of a program that takes an integer as a user input and compute all prime numbers up to the integer using queues. Since the Queue is an interface in Java Library and the LinkedList class is one of the classes that implement it, we will be using an object of LinkedList as a Queue. You may only use Queue methods when dealing with your queue.

Instruction:

Assignment11 class

This class displays a menu for a user. If a user enters “E”, then it asks to enter a positive integer, and it needs to compute all prime numbers up to the integer n. This class is given by the instructor.

PrimeComputing class

You need to complete the following method.

public PrimeComputing(int enteredNum)

This is a constructor of the PrimeComputing class. It needs to initialize the instance variable n to the parameter value of enteredNum. It should also instantiate all queues, originalQueue, primeQueue, backupQueue. For the originalQueue, it needs to enqueue all integers from 2 up to n. For the instance variable lastPrime and primeCount, you can initialize them to a value that will work with code that you will write for other methods of the class.

public void computePrimesUpToN()

Please see PrimeComputing.java for instructions.

There are four parts to complete.
1. You will need to remove the first element from original queue and that will be your next prime number.
2. You need to enqueue this next prime number to the prime number queue.
3. You need to check integers in the original queue and see if any of them can be divided by the next prime number. If so, they need to be removed from the original queue. This process needs to be repeated until you reach a prime number in the original queue that is greater than the square root of the entered number n.
You will need to keep track of the last such prime that is used to divide other integers in the original queue. Note that this is not the largest prime number found.
4. After such loop, you will need to move all remaining integers in the original queue to the prime queue. Now the prime queue contains all prime numbers up to n. This will be printed in another method.

Requirements:

You need to implement this method using an object of the LinkedList class in java.util package to represent a Queue.

Input

The following files are the test cases that will be used as input for your program (Right-click and use “Save As”):

Test Case #1
Test Case #2
Test Case #3
Test Case #4

Output

The following files are the expected outputs of the corresponding input files from the previous section (Right-click and use “Save As”):

Test Case #1
Test Case #2
Test Case #3
Test Case #4

Error Handling

Your program is expected to be robust enough to pass all test cases. You may use the Scanner class, but are not limited to it, to handle your user input.

 

 
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code "Newclient" for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.