1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Oduvanchick [21]
3 years ago
10

For a project in C++ we are supposed toDesign a class named Month. The class should have the following private members:-name: a

string object that holds the name of the month, such as January.-monthName: an integer value that holds the number of the month. For example, January would be 1, February would be 2, and so on. Valid values for this variable should be from 1 to 12.In addition, provide the following member functions:-a default constructor that sets monthNumber to 1 and name to "January"-a constructor that accepts the name of the month as an argument and finds and prints how many days in that month. For example, January has 31 days, and so on.
Engineering
1 answer:
mart [117]3 years ago
7 0

Answer:

include <iostream>

using namespace std;

 

class Month

{

public:

 Month (char firstLetter, char secondLetter, char thirdLetter);

 

 Month (int monthNum);

.

 

 Month();

 void outputMonth_num();

 

 

 void outputMonthLetters();

private:

 int month;

};

 

 

int main ()

{

 //

 // Variable declarations

 //

 int monthNum;

 char firstLetter, secondLetter, thirdLetter;    

 char testAgain;              

 

 do {

 

   cout << endl;

   cout << "Testing the default constructor ..." << endl;

   Month defaultMonth;

   defaultMonth.outputMonth_num();

   defaultMonth.outputMonthLetters();

 

   //

   // Construct a month using the constructor with one integer argument

   //

   cout << endl;

   cout << "Testing the constructor with one integer argument..." << endl;

   cout << "Enter a month number: ";

   cin >> monthNum;

 

   Month testMonth1(monthNum);

   testMonth1.outputMonth_num();

   testMonth1.outputMonthLetters();

 

   //

   // Construct a month using the constructor with three letters as arguments

   //

   cout << endl;

   cout << "Testing the constructor with 3 letters as arguments ..." << endl;

   cout << "Enter the first three letters of a month (lowercase): ";

   cin >> firstLetter >> secondLetter >> thirdLetter;

   cout << endl;

 

   Month testMonth2(firstLetter, secondLetter, thirdLetter);

   testMonth2.outputMonth_num();

   testMonth2.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(char firstLetter, char secondLetter, char thirdLetter)

{

if ((firstLetter == 'j')&&(secondLetter == 'a')&&(thirdLetter == 'n'))

  outputMonth_num = 1;

if ((firstLetter == 'f')&&(secondLetter == 'e')&&(thirdLetter == 'b'))

  outputMonth_num = 2;

if ((firstLetter == 'm')&&(secondLetter == 'a')&&(thirdLetter == 'r'))

  outputMonth_num = 3;

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

  outputMonth_num = 4;

if ((firstLetter == 'm')&&(secondLetter == 'a')&&(thirdLetter == 'y'))

  outputMonth_num = 5;

if ((firstLetter == 'j')&&(secondLetter == 'u')&&(thirdLetter == 'n'))

  outputMonth_num = 6;

if ((firstLetter == 'j')&&(secondLetter == 'u')&&(.thirdLetter == 'l'))

  outputMonth_num = 7;

if ((firstLetter == 'a')&&(secondLetter == 'u')&&(thirdLetter == 'g'))

  outputMonth_num = 8;

if ((firstLetter == 's')&&(secondLetter == 'e')&&(thirdLetter == 'p'))

  outputMonth_num = 9;

if ((firstLetter == 'o')&&(secondLetter == 'c')&&(thirdLetter == 't'))

  outputMonth_num = 10;

if ((firstLetter == 'n')&&(secondLetter == 'o')&&(thirdLetter == 'v'))

 outputMonth_num = 11;

if ((firstLetter == 'd')&&(secondLetter == 'e')&&(thirdLetter == 'c'))

 outputMonth_num = 12;

}

 

Month::inputMonthByNumber

{

if (Month_num > 12 && Month_num < 1)

cout << "Invalid number for Month, please choose 1-12)\n";

}

 

void Month::outputMonth_num()

{

 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;

   }

}

You might be interested in
Based on the graphs of stress-strain from the V-MSE site, how would you characterize the general differences between polymers an
Pepsi [2]

Answer:

Option A

Explanation:

Alloys are metal compounds with two or more metals or non metals to create new compounds that exhibit superior structural properties. Alloys have high level of hardness that resists deformation thereby making it less ductile compared to polymers. This is due to the varying difference in the chemical and physical characteristics of the constituent metals in the alloy.

6 0
3 years ago
What is soil texture in civil engineering​
Bond [772]

Answer:

It will indicate the percentage of sand, silt, and clay present in the soil.

Explanation:

4 0
2 years ago
If you replace the text value in an associative dimension, the text value will not change when the
Nostrana [21]

Answer:

C

Explanation:

7 0
3 years ago
Explain The Basic Difference Between Bs2 And Bs3 Engine.​
snow_tiger [21]

Answer:

The main difference between the bs2 and bs3 engine is to present in the catalytic converter. And in bs2 engines the catalytic converter is does not used for the formation of hc and co. In bs3 engine there is no harmful emissions in the hc and co

3 0
2 years ago
Two technicians are discussing cylinder honing technician a says a good cross hatch helps to trap the oil and retain it in the c
aleksley [76]

er:

Explanation:Technician A says that primary vibration is created by slight differences in the inertia of the pistons between top dead center and bottom dead center. Technician B says that secondary vibration is a strong low-frequency vibration caused by the movement of the piston traveling up and down the cylinder. Who is correct? O A. Neither Technician A nor B OB. Technician B O C. Both Technicians A and B D. Technician A​

8 0
2 years ago
Other questions:
  • Interlocking stacked material is done by​ _____.
    10·2 answers
  • A typical aircraft fuselage structure would be capable of carrying torsion moment. a)True b)- False
    12·1 answer
  • Using leftover paint colors is acceptable in a paint shop and will help cut down on waste.
    13·2 answers
  • What effect will increasing numbers of high-profile green building projects likely have on thinking about building?
    5·1 answer
  • Can you guys please introduce yourself​
    15·2 answers
  • Recommend the types of engineers needed to collaborate on a city project to build a skateboard park near protected wetlands.
    6·1 answer
  • a buyer can purchase 70 screwdrivers ten 4-inch length twelve 6 inch length twenty 8-inch length are needed. how many heavy 24-i
    6·1 answer
  • ) A flow is divided into two branches, with the pipe diameter and length the same for each branch. A 1/4-open gate valve is inst
    5·1 answer
  • Engine horsepower decreases ________% for every___________feet above sea level.
    9·1 answer
  • A seamless pipe carries 2400m³ of steam per hour at a pressure of 1.4N/mm².The velocity of flow is 30m/s.assuming the tensile st
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!