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
What are factor of safety for brittle and ductile material
galben [10]

Explanation:

Step1

Factor of safety is the number that is taken for the safe design of any component. It is the ratio of failure stress to the maximum allowable stress for the material.

Step2

It is an important parameter for design of any component. This factor of safety is taken according to the environment condition, type of material, strength, type of component etc.

Step3

Different material has different failure stress. So, ductile material fails under shear force. Ductile material’s FOS is based on yield stress as failure stress as after yield point ductile material tends to yield. Brittle material’s FOS is based on ultimate stress as failure stress.

The expression for factor of safety for ductile material is given as follows:

FOS=\frac{\sigma_{yp}}{\sigma_{a}}

Here,\sigma_{f} is yield stress and \sigma_{a} is allowable stress.

The expression for factor of safety for brittle material is given as follows:

FOS=\frac{\sigma_{ut}}{\sigma_{a}}

Here,\sigma_{ut} is ultimate stress and \sigma_{a} is allowable stress.

5 0
3 years ago
What is the command this line of code is telling the robot?
podryga [215]

Answer:

drive the car

Explanation:

4 0
3 years ago
Read 2 more answers
The coolant heat storage system:
Monica [59]

Answer:

c

Explanation:

This is because many things, such as pcs, over heat

8 0
3 years ago
Is EPA is the organization that was formed to ensure safe and health working conditions for workers by setting and enforcing sta
mr_godi [17]
Let me search this up
3 0
2 years ago
The angle of twist can be computed using the material’s shear modulus if and only if: (a)- The shear stress is still in the elas
ollegr [7]

Answer:

The angle of twist can be computed using the material’s shear modulus if and only if the shear stress is still in the elastic region

Explanation:

The shear modulus (G) is the ratio of shear stress to shear strain. Like the modulus of elasticity, the shear modulus is governed by Hooke’s Law: the relationship between shear stress and shear strain is proportional up to the proportional limit of the material. The angle of twist can be computed using the material’s shear modulus if and only if the shear stress is still in the elastic region.

3 0
3 years ago
Other questions:
  • Dr. Thermo, only has one bottle of neon. However, he needs to run two experiments, each requiring its own bottle. Therefore, he
    13·1 answer
  • Consider a single crystal of some hypothetical metal that has the BCC crystal structure and is oriented such that a tensile stre
    10·1 answer
  • Nitrogen enters a steady-flow heat exchanger at 150 kPa, 10°C, and 100 m/s, and it receives heat as it flows through it. Nitroge
    15·1 answer
  • A water agency stated that waterlines cannot have water flowing faster than 8 ft/s. What is the minimum standard pipe diameter t
    12·1 answer
  • (a) The lattice constant of GaAs is 5.65 Å. Determine the number of Ga atoms andAs atoms per cm 3 .
    15·1 answer
  • What are the functions of the peripheral nervous system
    6·2 answers
  • Which of the following addresses future implications of design and process decisions?
    5·1 answer
  • Explain moment of inertia<br>​
    9·1 answer
  • The use of seatbelts in a car has significantly reduced the number of crash fatalities. Which statement best explains how societ
    11·1 answer
  • For a small company it's usually best to keep the corporate and brand image as___ as possible​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!