473,394 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

primecheck

1
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.
Nov 9 '06 #1
1 1336
sicarie
4,677 Expert Mod 4TB
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.
Cool, sounds like a good assignment. Are you having trouble with a specific part of it?
Nov 9 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

80
by: xicloid | last post by:
I'm making a function that checks the input integer and returns the value if it is a prime number. If the integer is not a prime number, then the function should return nothing. Problem is, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.