Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write algorithms and programs to create a class PrimeSequence that implements the Sequence interface. Provide a Demo class that will produce an arbitrary sequence of

Write algorithms and programs to create a class PrimeSequence that implements the Sequence interface.

Provide a Demo class that will produce an arbitrary sequence of n prime numbers in table format and will perform an analysis of those n prime numbers.

Output: Output will provide a table of n prime numbers. The table will be as close to 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, may be scaled, and each entry must fit on a single row. All output should be handled by the Demo class. Additional details of the histogram will be discussed in class.

Input: Input will be provided by the command-line. Two input constants will be placed on the command-line upon execution. For example: java SequenceDemo 6 50 ; where the prime sequence will start with the next prime after the first number, and the second number (n) is the number of prime numbers to be sequenced. Both numbers will be integers and both numbers must be 1 or greater. Instructions for compilation/execution should include command-line input details.

REQUIREMENTS:

No switch or breaks statements allowed.

You must write at least THREE programs: one will be the Sequence interface with a next() method; one will be the PrimeSequence class that will implement the interface; and one will be the SequenceDemo class that will perform the demonstration/analysis.

The Sequence interface will provide for the next() method. Interface will use class documentation standards.

The PrimeSequence class will implement the next() method, a method to determine if a number is prime, and any other methods/instance variables required for the class.

The SequenceDemo class will accept and validate the command-line input, request the specified number (n) of primes, starting were specified, collecting data for analysis, and preparing the table for output. The analysis will entail counting how many instances of each digit [0-9] occur on the last digit of each prime.

MUST BE DONE IN JAVA

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions