Question: Help with pseudocode only!!!! Write algorithms and programs to create a class PrimeSequence that ……

Help with pseudocode only!!!!

Write algorithms and programs to create a class PrimeSequence that implements the Sequence interface – refer to P10.2 on page 508 in the text – and the next() method. This problem utilizes the Worked Example 10.1 (page 473 in the text – go to for sample downloads). Provide a Demo program that will produce an arbitrary sequence of n prime numbers in table format and will perform an analysis of those n prime numbers.

Don't use plagiarized sources. Get Your Custom Essay on
Question: Help with pseudocode only!!!! Write algorithms and programs to create a class PrimeSequence that ……
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay

Output: Output will provide a table of n prime numbers. The table will be as close to b“square” as possible – i.e. same number of rows and columns – with at most 10 entries per row. All entries will be right-aligned. Additionally, output will include a “histogram” of the occurrences of the last digit [0-9] of each prime number. The histogram will be horizontal (not vertical) and will be scaled (as a percentage %), with a legend at the bottom to explain the scale and display the total count of primes. Each digit’s entry (a sequence of *’s) must fit on a single row, and it must be properly labeled (actual count, scaled %). Scale will need to be flexible. Round up fraction percentages. All output should be handled by the Demo class. A sample output is provided below.

Input: Input will be provided on the command-line (see 11.3, pages 527-529 for details). Two input constants will be placed on the command-line upon execution. For example: java SequenceDemo 2 25 ; where the prime sequence will start with the next prime after the first number (3), and the second number (n) is the number of prime numbers to be sequenced (25). Both numbers will be integers and both numbers must be 1 or greater. Command-line input will need to be validated. If either input fails validation, your program should display why the input failed, and it should gracefully terminate, using System.exit(1). Instructions for compilation/execution should include command-line input details and requirements, and document that the Sequence interface needs to be in the same directory with your source code.

Expert Answer


public class PrimeSequenceTester {

    public static void main(String[] args) {

        final int TARGET_NUMBER_OF_PRIMES = 100;
Sequence primes = new PrimeSequence();

        System.out.println(“The first ” + TARGET_NUMBER_OF_PRIMES + ” prime numbers are as follows:n”);

        for (int index = 1; index <= TARGET_NUMBER_OF_PRIMES; index++) {
// formats the output with each element in a field of length 4
if (index % 10 == 0) {


public class PrimeSequence implements Sequence {

    private int number = 1;

    // Cycles through each number testing their prime status
public int next() {
boolean primeFlag = false;
while (!primeFlag) {
primeFlag = isPrime(number);
return number;

    // Determines if a number is prime
public boolean isPrime(int number) {
boolean factorFlag = false;
int divisor = 2;
while (!factorFlag && divisor <= Math.sqrt(number)) {
if (number % divisor == 0) {
factorFlag = true;
return !factorFlag;

public interface Sequence {

    // Finds the next element in a sequence.

    int next();
PrimeSequence ldeaProjects/PrimeSequence src/PrimeSequenceTester java [PrimeSequence Project 1public class PrimeSequenceTester idea out public static void main(Stringll args) t final int TARGET_NUMBER_OF_PRIMES 188 PrimeSequence Sequence primes-new PrineSequenceC) System.out.println(The fist TARGET NUMBER OF_PRIMESprime numbers are as follows:n); for (int index=1; index<= TARGET NUMBER-OF-PRIMES; index++) { C PrimeSequenceTester Sequence 18 // formats the output with each element in a field of length 4 Systen.out.printf(%4d, primes . next()); if ( index 10-_ 0) { External Libraries 12 13 14 15 16 17 18 19 20 21 System.out.println); System.out.println) PrimeSequenceTester Run Main 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 481 409 419 421 431 433 439 443 449 457 461 463 Ш 467 479 487 491 499 503 509 521 523 541 Process finished with exit code 19:6 LF# UTF-8

Top Grade Homework
Order NOW For a 10% Discount!
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.


Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.


Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.


Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.


Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.

× Contact Live Agents