Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include using namespace std; class Countertype { int count; public: void setcounter(int); void increasecount(); void decreasecount(); void returncounter(); void outputcount(); }; void Countertype::setcounter(int c) {

#include  using namespace std; class Countertype { int count; public: void setcounter(int); void increasecount(); void decreasecount(); void returncounter(); void outputcount(); }; void Countertype::setcounter(int c) { int count = c ; if (count < 0) { cout << "Invalid number! NUmber must be positive ."; } } void Countertype::increasecount() { count++; if (count < 0) { cout << "Can't be counted!"; count = 0; } } void Countertype::decreasecount() { count--; if (count < 0) { cout << "Can't be counted!"; count = 0; } int Countertype::returncounter() { return count; } void Countertype::outputcount(); { cout << count; } int main() { cout << "Welcome to my program:"; int c; Countertype countt; cout << " Type number: "; cin << c; countt.setcounter(c); cout << " Result of number after increase one value: "; countt.increasecount(); cout << " Value returned: "; countt.returnvalue(); cout <<" Result of number after decrease one value: "; cout << "Value returned: "; countt.returnvalue(); cout << " Final value of number: "; countt.output(); return 0; } 

My program doesn't work. Can you fix it?

Its Counting program Define 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 a mutator function that sets the counter to a count given as an argument. Include member functions to increase the count by one and to decrease the count by one. Be sure that no member function allows the value of the counter to become negative. Also, include a member function that returns the current count value and one that outputs the count. Embed your class definition in a test program

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

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions