Develop a C++ class called PrimeNumberGenerator. An object of this class will generate successive prime numbers on request. Think of the object as being similar to the digital tasbeeh counter. It has a reset button which makes the counter return to 0. There is also a button to get the next prime number. On the tasbeeh, pressing this button increments the current value of the counter. In your object, pressing this button would generate the next prime number for display. You’ll implement the reset button as a member function reset() and the other button as a function getNextPrime(). When an object is first created and the getNextPrime() function is called, it will return the first prime number, i.e., 2. Upon subsequent calls to the getNextPrime() function, the subsequent prime numbers will be returned. Define any others functions such as constructor and attributes that you need.   According to Wikipedia: “a prime number is a natural number greater than 1, that has no positive divisors other than 1 and itself.”   Expected Input/Output:   Enter 1 if you want to reset   Enter 2 if you want to get next prime number   Enter -1 to quit: 1   Counter value: 0   Enter 1 if you want to reset   And 2 if you want to get next prime number: 2   Counter value: 2   Enter 1 if you want to reset   And 2 if you want to get next prime number: 2   Counter value: 3   Enter 1 if you want to reset   And 2 if you want to get next prime number: 2   Counter value: 5   Enter 1 if you want to reset   And 2 if you want to get next prime number: -1   (Object oriented programming c++ question)

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter6: Looping
Section: Chapter Questions
Problem 4GZ
icon
Related questions
Question
100%

Develop a C++ class called PrimeNumberGenerator. An object of this class will generate successive prime numbers on request. Think of the object as being similar to the digital tasbeeh counter. It has a reset button which makes the counter return to 0. There is also a button to get the next prime number. On the tasbeeh, pressing this button increments the current value of the counter. In your object, pressing this button would generate the next prime number for display. You’ll implement the reset button as a member function reset() and the other button as a function getNextPrime(). When an object is first created and the getNextPrime() function is called, it will return the first prime number, i.e., 2. Upon subsequent calls to the getNextPrime() function, the subsequent prime numbers will be returned. Define any others functions such as constructor and attributes that you need.

 

According to Wikipedia: “a prime number is a natural number greater than 1, that has no positive divisors other than 1 and itself.”

 

Expected Input/Output:

 

Enter 1 if you want to reset

 

Enter 2 if you want to get next prime number

 

Enter -1 to quit: 1

 

Counter value: 0

 

Enter 1 if you want to reset

 

And 2 if you want to get next prime number: 2

 

Counter value: 2

 

Enter 1 if you want to reset

 

And 2 if you want to get next prime number: 2

 

Counter value: 3

 

Enter 1 if you want to reset

 

And 2 if you want to get next prime number: 2

 

Counter value: 5

 

Enter 1 if you want to reset

 

And 2 if you want to get next prime number: -1

 

(Object oriented programming c++ question)

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT