Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 300 Weeks Ago, 3 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 14 Sep 2017 My Price 10.00

abstract data type

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). The complete class will 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 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 first three letters in the name of the month,
and a member function that returns the next month as a value of type Month.

For this problem write part of the class - the default constructor and the constructor
with one integer argument, the two output functions, and the next month function.
Embed the class definition in a test program.

// *************************************************************
//
// NextMonth.cpp
//
// This program defines and tests a class named Month.
// The class has one member variable (an integer) to represent
// the month. It has a constructor to set the month using an
// integer argument (1 for January, 2 for February, and so
// forth), a default constructor that sets the month to 1
// (January), 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.
//
// *************************************************************

#include <iostream>
using namespace std;

//
// Definition of the Month class
//
class Month
{
public:

Month (int monthNum);
// Precondition: The parameter monthNum contains a valid
// month number (1 - 12)
// Postcondition: The member variable month has been set to
// the value of the parameter monthNum.

Month();
// Sets the member variable month to 1 (defaults to January).

void outputMonthNumber();
// Postcondition: The member variable month has been output
// to the screen if it is valid; otherwise a "not valid"
// message is printed.

void outputMonthLetters();
// Postcondition: The first three letters of the name of the
// month has been output to the screen if the month is
// valid (1 - 12); otherwise a message indicating the month
// is not valid is output.

Month nextMonth();
// Precondition: The month is defined and valid.
// Returns the next month as an object of type Month.

private:
int month;
};


int main ()
{
//
// Variable declarations
//
int monthNum;
char letter1, letter2, letter3; // first 3 letters of a month
char testAgain; // y or n - loop control

//
// Loop to test the next month function
//
do {

cout << endl;
cout << "Enter a month number: ";
cin >> monthNum;

Month testMonth(monthNum);
cout << endl;
cout << "This month ..." << endl;
testMonth.outputMonthNumber();
testMonth.outputMonthLetters();

Month next = testMonth.nextMonth();
cout << endl;
cout << "Next month ..." << endl;
next.outputMonthNumber();
next.outputMonthLetters();

//
// See if user wants to try another month
//
cout << endl;
cout << "Do you want to test again? (y or n) ";
cin >> testAgain;
}
while (testAgain == 'y' || testAgain == 'Y');

return 0;
}


Month::Month()
{
month = 1;
}


Month::Month (int monthNum)
{
if(MonthNum >= 1 && MonthNum <=12)
{
month=MonthNum;
else{
   month=1;
}
  
}

void Month::outputMonthNumber()
{
if (month >= 1 && month <= 12)
cout << "Month: " << month << endl;
else
cout << "Error - The month is not a valid!" << endl;
}


void Month::outputMonthLetters()
{
switch (month)
{
case 1:
cout << "Jan" << endl;
break;
case 2:
cout << "Feb" << endl;
break;
case 3:
cout << "Mar" << endl;
break;
case 4:
cout << "Apr" << endl;
break;
case 5:
cout << "May" << endl;
break;
case 6:
cout << "Jun" << endl;
break;
case 7:
cout << "Jul" << endl;
break;
case 8:
cout << "Aug" << endl;
break;
case 9:
cout << "Sep" << endl;
break;
case 10:
cout << "Oct" << endl;
break;
case 11:
cout << "Nov" << endl;
break;
case 12:
cout << "Dec" << endl;
break;
default:
cout << "Error - the month is not a valid!" << endl;
}
}


   // --------------------------------
   // ----- ENTER YOUR CODE HERE -----
   // --------------------------------
Month::Month(char fL, char sL, char tL)
{
/**
*check to for the first characters or letter of the month
*prints the month based on the characters user input
*check if the characters is valid
*/
if(fL >= 65 && fL <= 90){
fL += 32;
}
if(sL >= 65 && sL <= 90){
sL += 32;
}
if(tL >= 65 && tL <= 90){
tL += 32;
}
  
if(fL == 'j' && sL == 'a' && tL == 'n'){
month = 1;
}
else if(fL == 'f' && sL == 'e' && tL == 'b'){
month = 2;
}
else if(fL == 'm' && sL == 'a' && tL == 'r'){
month = 3;
}
else if(fL == 'a' && sL == 'p' && tL == 'r'){
month = 4;
}
else if(fL == 'm' && sL == 'a' && tL == 'y'){
month = 5;
}
else if(fL == 'j' && sL == 'u' && tL == 'n'){
month = 6;
}
else if(fL == 'j' && sL == 'u' && tL == 'l'){
month = 7;
}
else if(fL == 'a' && sL == 'u' && tL == 'g'){
month = 8;
}
else if(fL == 's' && sL == 'e' && tL == 'p'){
month = 9;
}
else if(fL == 'o' && sL == 'c' && tL == 't'){
month = 10;
}
else if(fL == 'n' && sL == 'o' && tL == 'v'){
month = 11;
}
else if(fL == 'd' && sL == 'e' && tL == 'c'){
month = 12;
}
else{
month = 0;
cout << "Invalid Month!" << endl;
}
}

   // --------------------------------
   // --------- END USER CODE --------
   // --------------------------------

Answers

(5)
Status NEW Posted 14 Sep 2017 07:09 PM My Price 10.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)