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)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education