Question: our goal is to write a program to find good prime numbers using the sieve of Eratosthenes. A good prime number is a number which:

our goal is to write a program to find good prime numbers using the sieve of Eratosthenes. A
good prime number is a number which:
Is a prime number
Is between a given lower and upper bound
Does not contain a given digit
2. Problem
You are to create a C++ project called sieve, a C++ source file called sieve.cpp, and struct inside it
called PrimesEratosthenesSieve that finds good prime numbers. The program asks the user for a
lower bound, an upper bound, and a bad digit, and then finds good primes which are greater than
or equal to the lower bound and less than or equal to the upper bound and do not contain the bad
digit. When there is only one line of good prime numbers in the output, the numbers should be
displayed with one space between each (and no space at the end). When there are multiple lines of
output, the numbers should be right-aligned to the width of the largest good prime. See below.
3. Tips
1. Use the template file found in Canvas. The framework for the program is there, and you will
need to fill in the methods. You MUST use the given members and methods to solve the
problem.
2. You MUST dynamically allocate the primes_ bool array. Dont forget to free any dynamically
allocated memory.
3. If a function/method is inline, the compiler places a copy of the code of that
function/method at each point where it is called at compile time. inline is used for efficiency
with short (one-line) functions/methods
4. Look up setw in the iomanip library to set the width of a field that is to be outputted.
5. #include for the sqrt function.
6. You may have up to 80 characters on a line. If you cannot fit all the primes on one line, you
should wrap around to the next line. To find the width of the maximum prime value and how
many primes you can fit on a row, use the following code:
7. const int max_prime_width = num_digits(max_prime_);
const int primes_per_row =80/(max_prime_width +1);
8. Be sure to comment your code and put your name and Stevens pledge at the top.
9. Make sure your code works with the test script.
10. The algorithm for the sieve is found in the pseudocode below

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!