How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask LogicPro Your Own Question

LogicPro
LogicPro, Engineer
Category: Homework
Satisfied Customers: 9968
Experience:  Expert in Java C++ C C# VB Javascript Design SQL HTML
29751445
Type Your Homework Question Here...
LogicPro is online now
A new question is answered every 9 seconds

Im stuck on this question.... Define a class for a type

Resolved Question:

I'm stuck on this question....

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 default constructor that sets the counter to zero and a constructor
with one argument that sets the counter to the value specified by its argument.
Include member functions to increase the count by 1 and to decrease
the count by 1. 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 to a stream. The
member function for doing output will have one formal parameter of type
ostream for the output stream that receives the output. Embed your class
definition in a test program.


And this code has to be used.
int main( )
{
cout << "Testing the CounterType class";
CounterType testOne, testTwo(50);
cout << "\n\nInitial Values:\n" << testOne.getCount() << " ";
testTwo.outputCount(cout);
while (testOne.getCount() 30)
testTwo.minusOne();
cout << "\n\nFinal Values:\n" << testOne.getCount() << " ";
testTwo.outputCount(cout);
return 0;
}
Submitted: 1 year ago.
Category: Homework
Expert:  LogicPro replied 1 year ago.
Hi,
Welcome to JustAnswer.
My name is XXXXX XXXXX I will help you.
Which IDE you are using?
Customer: replied 1 year ago.

Visual Studio Ultimate 12

Expert:  LogicPro replied 1 year ago.
Please wait for 30 minutes for the answer.
Expert:  LogicPro replied 1 year ago.
Download answer from here: CounterType.cpp

You can ask me again using "For LogicPro only" at the start of your questions like other customers to get instant answers.
It will ensure that question is for me.
Please bookmark my profile page:
http://www.justanswer.com/homework/expert-logicpro/
so you can come back and ask me a question anytime.

Remember, if for any reason you are unsatisfied with my answer, we can continue the conversation until you’re satisfied and rate my answer as excellent. I can address follow up questions on original requirements at no extra charge and I’m always here to help.
Thank you for using JustAnswer!
Customer: replied 1 year ago.

the output is wrong it should be


 


Initial Values:


0 50


 


Final Values:


30 30


 


and the code is wrong: here your code


int main( )
{
cout << "Testing the CounterType class";
CounterType testOne, testTwo(50);
cout << "\n\nInitial Values:\n" << testOne.getCount() << " ";
testTwo.outputCount(cout);
while (testOne.getCount())
testTwo.minusOne();
cout << "\n\nFinal Values:\n" << testOne.getCount() << " ";
testTwo.outputCount(cout);
system ("pause");
return 0;
}


 


and here is my code:


int main( )
{
cout << "Testing the CounterType class";


 


CounterType testOne, testTwo(50);


 


cout << "\n\nInitial Values:\n" << testOne.getCount() << " ";
testTwo.outputCount(cout);


 


while (testOne.getCount() < 30)
testOne.plusOne();


 


while (testTwo.getCount() > 30)
testTwo.minusOne();


 


cout << "\n\nFinal Values:\n" << testOne.getCount() << " ";
testTwo.outputCount(cout);


 


return 0;
}

Expert:  LogicPro replied 1 year ago.
My Main function was given by you.
However I have changed it with your new code and it is giving output:

http://wikisend.com/download/508206/CounterType.cpp
.
LogicPro, Engineer
Category: Homework
Satisfied Customers: 9968
Experience: Expert in Java C++ C C# VB Javascript Design SQL HTML
LogicPro and 7 other Homework Specialists are ready to help you
Expert:  LogicPro replied 1 year ago.
Hi again,
Just following up with you to see how everything is going and if you have more questions for me.
You can ask me again using "For LogicPro only" at the start of your questions like you do to get instant answers.
It will ensure that question is for me.
Please bookmark my profile page:
http://www.justanswer.com/homework/expert-logicpro/
so you can come back and ask me a question anytime.
If you need any additional information on this answer, please don't hesitate to ask by clicking on 'Reply to Expert', and I will reply as soon as possible.
I hope you found the information in my answer helpful, and if so, please let me know, here. Thank you!
Thanks very much for using Just Answer!
Best wishes
LogicPro
Customer: replied 1 year ago.

Yes I have one question. For that Month.cpp you hepled me with, How can I have all the month number output on the same line and the month name on the same line?

Expert:  LogicPro replied 1 year ago.
Remove endl from the cout statement to print the output on the same line.

Customer: replied 1 year ago.

I tried that first. It didn't work.


 


 


Month m1;
m1.OutputAsInteger(cout);
m1.OutputAsChar(cout);

cout << endl <<"";
Month m2(2);
m2.OutputAsInteger(cout);
m2.OutputAsChar(cout);

cout << endl <<"" << endl;
Month m3(5);
m3.OutputAsInteger(cout);
m3.OutputAsChar(cout);

cout << "Enter a month value as a month number (1-12): ";
cin >> num;
Month m4(num);
m4.OutputAsInteger(cout);
m4.OutputAsChar(cout);

cout << endl << "Testing next month function on second initial Month value: " << endl;
char c1, c2, c3;
cout << "\nEnter a Month value as three character month (e.g., Jan): ";
cin >> c1 >> c2 >> c3;
Month m5(c1, c2, c3);
m5.OutputAsInteger(cout);
m5.OutputAsChar(cout);

Expert:  LogicPro replied 1 year ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
Customer: replied 1 year ago.

I was trying to make it look like this:


 


Initial Month values as month numbers:


1 2 5


Initial Month values as month names:


January Febrary May


 


But when I remove endl from method it doesnt look like this.

Expert:  LogicPro replied 1 year ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
Customer: replied 1 year ago.

That didnt work either. When the program is first ran it should show:


 


Initial Month values as month numbers:


 


1 2 5


 


Initial Month values as month names:


 


January Febrary May


 


Then I enter month function on second initial month value: (e.g. March)


 


Then I enter a month number: (e.g. 11 for November)


 


Then I enter month value name (e.g. December)


 


I hit enter and my inputting month values should show:



March December


 


for the two month names I enter.


 

Expert:  LogicPro replied 1 year ago.
What output exactly do you need, please let me know.
Customer: replied 1 year ago.

Month number Output:


1 2 5


 


Month name Output:


January Febrary May


 



(keyboard input any of the month names):


 


So the whole program will look like this:


 


Initial three month (number value) objects using three seperate constructors on same line:


1 2 5


Initial three month (name value) objects using three seperate constructors on same line:


January February May


 


Testing next month function on second initial Month value:


March


 


Enter a month value as a month number (1-12):13


(after enter the 13 it should output) Error invalid number


 


Enter a month value as Month name (e.g. January): December


 


results of inputting month values:


March December


 


Press any key to conitnue...


 


 


 


 


 


 


 

Expert:  LogicPro replied 1 year ago.
I will reply you in few hours.
Customer: replied 1 year ago.

ok

Expert:  LogicPro replied 1 year ago.
ok
Expert:  LogicPro replied 1 year ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
Customer: replied 1 year ago.

The code had an error


 


C2679: binary '>>' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

Expert:  LogicPro replied 1 year ago.
Use this statement, at the top of code:

#include<string>
Customer: replied 1 year ago.

I just figure it out myself. Thanks for everything it works perfect.

Expert:  LogicPro replied 1 year ago.
great
Customer: replied 1 year ago.

Enter a month value as a month number (1-12):13


 


How can I get the number to input after the error message. this is my last question

Expert:  LogicPro replied 1 year ago.
I will check it
Expert:  LogicPro replied 1 year ago.
Replace these two lines:

cout << "Enter a month number: ";
cin >> num;

with

do {
cout << "Enter a month value as a month number (1-12): ";
cin >> num;
if(num<1 || num>12) {
cout<<"Invalid month number.";
}
}while(num<1 || num>12);
Customer: replied 1 year ago.

Thanks again.

Expert:  LogicPro replied 1 year ago.
Welcome John

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Last | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4522
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4522
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3458
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3124
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2385
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1988
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1876
    Bachelors Degree and CPA with Accounting work experience
  • http://ww2.justanswer.com/uploads/avremote/photoa.jpg Seanna's Avatar

    Seanna

    Tutor

    Satisfied Customers:

    1781
    3,000+ satisfied customers, all topics, A+ work
 
 
 
Chat Now With A Tutor
LogicPro
LogicPro
3728 Satisfied Customers
Expert in Java C++ C C# VB Javascript Design SQL HTML