Hi Im a beginner in C++. I tried to do these but couldnt.
Pls hekp me to do these. thanks.
1. Design and implement a class called PrimeChecker. An instance of this
class will be able to check if a number between 2-10000 is prime. The class
stores the consecutive primes 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 in an array and uses
these to check if the given number is prime.
The class has the following public methods:
(a) Constructor
(b) Destructor
(c) IsPrime() which takes a parameter which is an integer in the range
1-10000 and returns a boolean.
2. Extend the class above so that if the number x (which may now be more
than 10000) to check is greater than the square of the largest prime in
the list of consecutive primes then the class adds new consecutive primes
to its internal array (the largest prime it adds is just greater than the
square-root of x.). Assume that you will never need to hold more
than 1000 consecutive primes.
Pls hekp me to do these. thanks.
1. Design and implement a class called PrimeChecker. An instance of this
class will be able to check if a number between 2-10000 is prime. The class
stores the consecutive primes 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 in an array and uses
these to check if the given number is prime.
The class has the following public methods:
(a) Constructor
(b) Destructor
(c) IsPrime() which takes a parameter which is an integer in the range
1-10000 and returns a boolean.
2. Extend the class above so that if the number x (which may now be more
than 10000) to check is greater than the square of the largest prime in
the list of consecutive primes then the class adds new consecutive primes
to its internal array (the largest prime it adds is just greater than the
square-root of x.). Assume that you will never need to hold more
than 1000 consecutive primes.
Comment