Homework

Homework Questions? Ask a Tutor for Answers ASAP

Ask an Expert,
Get an Answer ASAP!

Homework
This answer was rated:

Define a class called Month that is an abstract data type for

a month. Your class will have...
Define a class called Month that is an abstract data type for a month. Your
class will have one member variable of type int to represent a month (1 for January, 2 for February, and so forth). Include all the following
member functions: a constructor to set the month using the first three letters
in the name of the month as three arguments, a constructor to set the
month using an integer as an argument (1 for January, 2 for February, and
so forth), a default constructor, an input function that reads the month as
an integer, an input function that reads the month as the first three letters
in the name of the month, an output function that outputs the month as
an integer, an output function that outputs the month as the first three
letters in the name of the month, and a member function that returns the
next month as a value of type Month. The input and output functions will
each have one formal parameter for the stream. Embed your class definition
in a test program.
Show More
Show Less
Ask Your Own Homework Question
Answered in 9 minutes by:
9/22/2013
LogicPro
LogicPro, Engineer
Category: Homework
Satisfied Customers: 13,230
Experience: Expert in Java C++ C C# VB Javascript Design SQL HTML
Verified
Hi,
Welcome to JustAnswer.
My name is XXXXX XXXXX I will help you.
Do you have code to start with?
What is the deadline?
Ask Your Own Homework Question
Customer reply replied 4 years ago

Deadline is tomorrow evening.


 


#include <iostream>
using namespace std;

class Month
{
public:
Month (char firstLetter, char secondLetter, char thirdLetter);
Month (int month);
Month ();
void Input (istream& ins);
void Output(ostream& outs);
Month next();

private:
int Month_Number;
};

int main ()
{
//Month m1(6);
Month m2('F','e','b');
Month m3;

//m1.Output (cout);
//m2.Output(cout);
cout << "\nSolution to CSC-160 Homework Four Project 6\n ";
cout << "\nTesting the Month class\n";
cout << "\nCreating three Month objects using three seperate constructors.\n";
cout << "\nInitial Month values as month numbers:\n";
cout << "\nInitial Month values as month names:\n";
cout << "\nTesting next month functionon second initial value:\n";
cout << "Enter a Month value as a month number (1-12): ";
m3.Input(cin);
m2.Output(cout);

return 0;
}

Month::Month() : Month_Number(0){}

void Month::Input(istream& ins)
{
char c, firstLetter, secondLetter, thirdLetter ;
int i;

c = ins.peek();



if ( (c >= '1') && (c <= '9') )
ins >> i;
else
ins >> firstLetter >> secondLetter >> thirdLetter;
}


Month::Month(char firstLetter, char secondLetter, char thirdLetter)
{
firstLetter = tolower(firstLetter);
secondLetter = tolower(secondLetter);
thirdLetter = tolower(thirdLetter);

if ((firstLetter == 'j')&&(secondLetter == 'a')&&(thirdLetter == 'n'))
Month_Number = 1;
else if ((firstLetter == 'f')&&(secondLetter == 'e')&&(thirdLetter == 'b'))
Month_Number = 2;
else if ((firstLetter == 'm')&&(secondLetter == 'a')&&(thirdLetter == 'r'))
Month_Number = 3;
else if ((firstLetter = 'a')&&(secondLetter == 'p')&&(thirdLetter == 'r'))
Month_Number = 4;
else if ((firstLetter == 'm')&&(secondLetter == 'a')&&(thirdLetter == 'y'))
Month_Number = 5;
else if ((firstLetter == 'j')&&(secondLetter == 'u')&&(thirdLetter == 'n'))
Month_Number = 6;
else if ((firstLetter == 'j')&&(secondLetter == 'u')&&(thirdLetter == 'l'))
Month_Number = 7;
else if ((firstLetter == 'a')&&(secondLetter == 'u')&&(thirdLetter == 'g'))
Month_Number = 8;
else if ((firstLetter == 's')&&(secondLetter == 'e')&&(thirdLetter == 'p'))
Month_Number = 9;
else if ((firstLetter == 'o')&&(secondLetter == 'c')&&(thirdLetter == 't'))
Month_Number = 10;
else if ((firstLetter == 'n')&&(secondLetter == 'o')&&(thirdLetter == 'v'))
Month_Number = 11;
else if ((firstLetter == 'd')&&(secondLetter == 'e')&&(thirdLetter == 'c'))
Month_Number = 12;
else
cout << "Error : invalid month number: " << endl;
exit(1);
}

Month::Month (int month)
{
if ((month < 1) || (month > 12))
{
cout << "Error : invalid month number: " << endl;
exit(1);
}
else
Month_Number = month;

}
void Month::Output(ostream& outs)
{

switch (Month_Number)
{
case 1:
outs << "January";
break;
case 2:
outs << "February";
break;
case 3:
outs << "March";
break;
case 4:
outs << "April";
break;
case 5:
outs << "May";
break;
case 6:
outs << "June";
break;
case 7:
outs << "July";
break;
case 8:
outs << "August";
break;
case 9:
outs << "September";
break;
case 10:
outs << "October";
break;
case 11:
outs << "November";
break;
case 12:
outs << "December";
break;
default:
outs << "Error : invalid month number: " << endl;
}

cout << "\n";
}

Month Month::next()
{
int Num;

if (Month_Number == 12)
Num = 1;
else
Num = Month_Number + 1;

return(Month (Num));


}
public:
Month (char firstLetter, char secondLetter, char thirdLetter);
//Set the name of the month to the first 3 chars of its name

Month (int month);
//Set the months to their respective numbers

Month ();
//Initialize the Month name to "", and the month # XXXXX 0

void Input (istream& ins);
//reads either the month name or the month number

void Output(ostream& outs);
//Prints the full name of the month

Month next();
//returns the next month as a value of type Month.


private:
int Month_Number;
};

int main ()
{
//Month m1(6);
//Month m2('F','e','b');
Month m3;

//m1.Output (cout);
//m2.Output(cout);
cout << "Please enter month number or name: ";
m3.Input(cin);
m3.Output(cout);

return 0;
}

Month::Month() : Month_Number(0){}

void Month::Input(istream& ins)
{
char c, firstLetter, secondLetter, thirdLetter ;
int i;

c = ins.peek();

//Deternime whether c is an integer of a character

if ( (c >= '1') && (c <= '9') )
ins >> i;
else
ins >> firstLetter >> secondLetter >> thirdLetter;
}


Month::Month(char firstLetter, char secondLetter, char thirdLetter)
{
//Make all char lowercase
firstLetter = tolower(firstLetter);
secondLetter = tolower(secondLetter);
thirdLetter = tolower(thirdLetter);

if ((firstLetter == 'j')&&(secondLetter == 'a')&&(thirdLetter == 'n'))
Month_Number = 1;
else if ((firstLetter == 'f')&&(secondLetter == 'e')&&(thirdLetter == 'b'))
Month_Number = 2;
else if ((firstLetter == 'm')&&(secondLetter == 'a')&&(thirdLetter == 'r'))
Month_Number = 3;
else if ((firstLetter = 'a')&&(secondLetter == 'p')&&(thirdLetter == 'r'))
Month_Number = 4;
else if ((firstLetter == 'm')&&(secondLetter == 'a')&&(thirdLetter == 'y'))
Month_Number = 5;
else if ((firstLetter == 'j')&&(secondLetter == 'u')&&(thirdLetter == 'n'))
Month_Number = 6;
else if ((firstLetter == 'j')&&(secondLetter == 'u')&&(thirdLetter == 'l'))
Month_Number = 7;
else if ((firstLetter == 'a')&&(secondLetter == 'u')&&(thirdLetter == 'g'))
Month_Number = 8;
else if ((firstLetter == 's')&&(secondLetter == 'e')&&(thirdLetter == 'p'))
Month_Number = 9;
else if ((firstLetter == 'o')&&(secondLetter == 'c')&&(thirdLetter == 't'))
Month_Number = 10;
else if ((firstLetter == 'n')&&(secondLetter == 'o')&&(thirdLetter == 'v'))
Month_Number = 11;
else if ((firstLetter == 'd')&&(secondLetter == 'e')&&(thirdLetter == 'c'))
Month_Number = 12;
else
cout << "Error - This month is not a valid!" << endl;
exit(1);
}

Month::Month (int month)
{
if ((month < 1) || (month > 12))
{
cout << "Error - This month is not a valid!" << endl;
exit(1);
}
else
Month_Number = month;

}
void Month::Output(ostream& outs)
{

switch (Month_Number)
{
case 1:
outs << "January";
break;
case 2:
outs << "February";
break;
case 3:
outs << "March";
break;
case 4:
outs << "April";
break;
case 5:
outs << "May";
break;
case 6:
outs << "June";
break;
case 7:
outs << "July";
break;
case 8:
outs << "August";
break;
case 9:
outs << "September";
break;
case 10:
outs << "Octuber";
break;
case 11:
outs << "November";
break;
case 12:
outs << "December";
break;
default:
outs << "Error - This month is not a valid!" << endl;
}

cout << "\n";
}

Month Month::next()
{
int Num;

if (Month_Number == 12)
Num = 1;
else
Num = Month_Number + 1;

return(Month (Num));


}

Please wait while I review it
Ask Your Own Homework Question
Which C++ IDE you are using?
Ask Your Own Homework Question
Customer reply replied 4 years ago

Visual Studio Ultimate 2012

Please check back in 1 hour
Ask Your Own Homework Question
Customer reply replied 4 years ago

Ok. Thank You

Welcome John
Ask Your Own Homework Question
Download answer from here: MonthClass_CPP.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!
Ask Your Own Homework Question
Customer reply replied 4 years ago

Excellent work.


 


It should show these three months numbers ( 1 2 5)


and these three month names ( JAN FEB MAY)

It should show these three months numbers ( 1 2 5)

-> Do you mean, we should call defaul constructor 3 times for these numbers?

 

Also change the statement:

else if ((firstLetter = 'a')&&(secondLetter == 'p')&&(thirdLetter == 'r'))

to

else if ((firstLetter == 'a')&&(secondLetter == 'p')&&(thirdLetter == 'r'))

 

There was one '=' missing for firstLetter

 

 

Output will depand on input.

Hope it clears

Ask Your Own Homework Question
Customer reply replied 4 years ago

Yes call constructor 3 times

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.
LogicPro
LogicPro, Engineer
Category: Homework
Satisfied Customers: 13,230
Experience: Expert in Java C++ C C# VB Javascript Design SQL HTML
Verified
LogicPro and 87 other Homework Specialists are ready to help you
Ask your own question now
Ask LogicPro Your Own Question
LogicPro
LogicPro
LogicPro, Engineer
Category: Homework
Satisfied Customers: 13,230
13,230 Satisfied Customers
Experience: Expert in Java C++ C C# VB Javascript Design SQL HTML

LogicPro is online now

A new question is answered every 9 seconds

How JustAnswer works:

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

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

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!!!!

AlexLos 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.

GPHesperia, CA

I couldn't be more satisfied! This is the site I will always come to when I need a second opinion.

JustinKernersville, 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.

EstherWoodstock, 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.

RobinElkton, 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.

DianeDallas, TX

< Previous | Next >

Meet the Experts:

LogicPro

LogicPro

Engineer

13,230 satisfied customers

Expert in Java C++ C C# VB Javascript Design SQL HTML

Manal Elkhoshkhany

Manal Elkhoshkhany

Tutor

4,549 satisfied customers

More than 5000 online tutoring sessions.

Linda_us

Linda_us

Finance, Accounts & Homework Tutor

3,138 satisfied customers

Post Graduate Diploma in Management (MBA)

Chris M.

Chris M.

M.S.W. Social Work

2,635 satisfied customers

Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)

F. Naz

F. Naz

Chartered Accountant

2,158 satisfied customers

Experience with chartered accountancy

Bizhelp

Bizhelp

CPA

1,887 satisfied customers

Bachelors Degree and CPA with Accounting work experience

Seanna

Seanna

Tutor

1,781 satisfied customers

3,000+ satisfied customers, all topics, A+ work

< Previous | Next >

Related Homework Questions
I need some one to answere a couple excel question. Excel
I need some one to answere a couple excel question … read more
Jason Jones
Jason Jones
AAS Information Technology
6,316 satisfied customers
For LogicPro only: I need to develop a code using SQL for a
For LogicPro only: I need to develop a code using SQL for a cookbook database. Below are the requirements:Provide the SQL CREATE TABLE commands for the five tables in your cookbook database. Include P… read more
LogicPro
LogicPro
Engineer
13,230 satisfied customers
For a list of numbers entered by the user and terminated by
For a list of numbers entered by the user and terminated by 0. Write a program to find the sum of the positive numbers and the sum of the negative numbers. Needs to be done in Raptor Program.… read more
LogicPro
LogicPro
Engineer
13,230 satisfied customers
Program 1) A small company is moving all its employee data
Program 1) A small company is moving all its employee data to a computer. To make a smooth transition, a software program will permit the data entry personnel to enter data into a file. Design a progr… read more
LogicPro
LogicPro
Engineer
13,230 satisfied customers
Paul's missionary work created a controversy in the church.
Paul's missionary work created a controversy in the church. what was the nature of the Jew-Gentile controversy and how did the church handle it?… read more
Academic Tutor
Academic Tutor
Master\u0027s Degree
380 satisfied customers
Will your tutors assist with an entire exam? I have the
hello, will your tutors assist with an entire exam? … read more
David L.
David L.
Bachelor\u0027s Degree
6 satisfied customers
While arguing with his neighbor, pulls out a Swiss Army
While arguing with his neighbor, Sam pulls out a Swiss Army knife with the intent of merely frightening him. Sam accidentally hits his neighbor's arm with the knife, resulting in a slight nick. Unbekn… read more
RobertJDFL
RobertJDFL
Attorney
Juris Doctorate
5 satisfied customers
Need a biography on Woodrow to include the following info:
Angela, Need a biography on Woodrow Wilson to include the following info: 1. Term of presidency and date of service, date of birth, date of death, birthplace, and family history 2. Political affiliati… read more
Seanna
Seanna
Tutor
1,781 satisfied customers
Again) I have some more Algebra 1 questions for
Hello (again) I have some more Algebra 1 questions for participation.They are,What are two symbolic techniques used to solve a pair of simultaneous linear equations? Provide an example and solve it wi… read more
GLENN
GLENN
Master of Mathematics
328 satisfied customers
Scenario: You notice that the grass around your house is,
Scenario: You notice that the grass around your house is brown, short, and dead. The grass around your neighbor's house is green, tall, and alive. Read more: http://www.justanswer.com/questions/1qmxi-… read more
gpcomputer2000
gpcomputer2000
Bachelor's Degree
34 satisfied customers
Music exams Penn forster college 350700RR Medieval and
Music exams Penn forster college 350700RR Medieval and Renaissance Periods 1. A passage of music is marked "ritardando." The following passage is marked "a tempo." The composer is instructing the play… read more
Dr. Donna Kakonge
Dr. Donna Kakonge
Doctor of Education
179 satisfied customers
Critically evaluate the key developements of the NHS by
critically evaluate the key developements of the NHS by using or appraising the social economic factors as example… read more
ec92
ec92
Substitue teacher
Master\u0027s Degree
8 satisfied customers
Hope all is well. Need assistance on a homework assignment.
Hi, this is Brian hope all is well. Need assistance on a homework assignment. I'm coding a program in JavaScript language and need assistance in getting it to run. I have the container and code for th… read more
LogicPro
LogicPro
Engineer
13,230 satisfied customers
According to the university's website design request,
According to the university's website design request, students need to order five books, one for each of the five required courses that all students take. You need to design a program that will prompt… read more
Dr. Donna Kakonge
Dr. Donna Kakonge
Doctor of Education
179 satisfied customers
For LogicPro only: Design your own linked list class named
For LogicPro only: Design your own linked list class named IntList in C++ to hold a series of integers. Include the following public member functions, named as shown: Member Function Description Defau… read more
LogicPro
LogicPro
Engineer
13,230 satisfied customers
This an aspx.net question that has to be done in visual
Hello this an aspx.net question that has to be done in visual studio.I have the basic code but it is not working, just need corrections to be made to it. I need it by 11/18/17 Saturday… read more
LogicPro
LogicPro
Engineer
13,230 satisfied customers
125 word min. :What role did Enlightenment era philosophies
125 word min. :What role did Enlightenment era philosophies and the scientific revolution play in increasing resistance to centralized monarchies? What specific groups led the resistance, and how did … read more
Academic Tutor
Academic Tutor
Master\u0027s Degree
380 satisfied customers
For LogicPro only: Need help with by Tuesday, November 21st
For LogicPro only:Need help with by Tuesday, November 21st http://wikisend.com/download/607522 /CS150Project.pdfNeed Help with by Wednesday - November 22nd http://wikisend.com/download/275956/Homework… read more
LogicPro
LogicPro
Engineer
13,230 satisfied customers
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Show MoreShow Less

Ask Your Question

x