Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use C++ for this problem Implement a class for a type called CounterType. An object of this type is used to count things, so

Please use C++ for this problem

Implement a class for a type called CounterType. An object of this type is used to count things, so it records a count that is a nonnegative whole number. Include the following functions in your class: - a member mutator function that sets the counter to a number given as an argument - a member function that increases the count by 1 - a member function that decreases the count by 1 if it does not result in count becoming negative - a member function that returns the current value of count - a member function that prints the current value of count to standard output Write a test program for your class in main(). Your program should prompt the user to enter a positive value to initialize the CounterType object, then subtract 1 from the object and print out the current value, add 1 to count and print out the current value, and print out the final value. Sample 1: Enteranumbertostartwith:10 Thevalueaftersubtracting1:9 Thevalueafteradding1:10 Finalvalue:10 Sample 2: Enteranumbertostartwith:-2 Enterapositivevalue:2 Thevalueaftersubtracting1:1 Thevalueafteradding1:2 Finalvalue:2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AutoCAD Database Connectivity

Authors: Scott McFarlane

1st Edition

0766816400, 978-0766816404

More Books

Students also viewed these Databases questions

Question

How to find if any no. is divisble by 4 or not ?

Answered: 1 week ago

Question

Explain the Pascals Law ?

Answered: 1 week ago