Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using c++ Please make sure the code looks exactly the same as the sample when it is run. Implement a class for a type called

Using c++ Please make sure the code looks exactly the same as the sample when it is run.

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.

image text in transcribedimage text in transcribedimage text in transcribed

WORK AREA RESULTS a member function that returns the current value of count -a member function that prints the current value of count to standard outout Write a test program for your class in main). Your program should prompt the user to enter a positive value to initialize the CounterType obiect, 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 RUN # 1: ./CounterType Interactive SessonShow Invisibles Highlight: None # 1 Show Highlighted Only Enter a number to start with:10 The value after subtracting 1: 9 The value after adding 1: 10 Final valuei 10

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

Database Publishing With Filemaker Pro On The Web

Authors: Maria Langer

1st Edition

0201696657, 978-0201696653

More Books

Students also viewed these Databases questions

Question

How do other differentiating characteristics factor into OB?

Answered: 1 week ago

Question

What are the organizations immediate and long-range goals?

Answered: 1 week ago