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]
2 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]2 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
For the solidification of nickel, calculate the critical radius r* and the activation free energy ΔG* if nucleation is homogeneo
Fantom [35]

Answer:

????????????????

Explanation:

8 0
3 years ago
BE-14 Where must registration numbers be displayed?<br> Bow<br> Stern<br> Engine<br> 11<br> Transom
kondor19780726 [428]

Answer:

A. Bow

Explanation:

Registration number is an evidence or authentication of registration of a vessel or vehicle. This number is very important when an emergency occurs and there is a need to trace the vessel to the owner. And this should be displayed on a vertical surface or a surface where easy view is achievable.

So it is recommended that registration numbers be displayed on the bow of the vessel. The number should be displayed in such a way that it could be read from left to right.

6 0
3 years ago
Read 2 more answers
Can space debris take out a whole state
vodomira [7]
Yes depends how big the debris is
5 0
2 years ago
In a balanced three-phase wye–delta system, the source has an abc phase sequence and Van = 120∠40° V rms. The line and load impe
Step2247 [10]

Answer:

6.51∠-26.9° Amp - rms

Steps:

  1. This three-phase circuit will be equivalent to three single phase circuits in Y connection and we'll calculate current for ONE phase by dividing the load impedance by 3.
  2. By applying Ohm's law to the circuit, current will be calculated.
  3. Then the equivalent Delta current will be calculated by dividing it to sqrt(3)  and subtracting 30°

Explanations:

Source = 120∠40 V

Z-line=0.5+j0.4Ω

Z-load=24+j18Ω

<u>Converting Delta to Star</u>

Z-load-1Ф=Z-load-3Ф/3

=\frac{24+j18}{3}\\=8+j3

<u>Calculating Star Current by Ohm's Law:</u>

\frac{V}{Z-line+Z-load-1}\\ =\frac{120∠40}{(8+j6)+(0.5+j0.4)}

=11.27 A-rms

<u>Converting Star current to Delta Current</u>

I-delta=\frac{I-star}{\sqrt{3} } \leq -30

I-delta = 6.51∠-26.9°

8 0
3 years ago
If a thermostat is not working, what diagnostic trouble code could be set?
fredd [130]
P0128 it’s a DTC for coolant thermostat
4 0
2 years ago
Other questions:
  • Pick a subjectarea/field/topic that you are interested in. For each of the following Bonham- Carver uses of GIS give an example
    7·1 answer
  • 2. In the above figure, what type of cylinder arrangement is shown in the figure above?
    9·2 answers
  • Define a function pyramid_volume with parameters base_length, base_width, and pyramid_height, that returns the volume of a pyram
    10·1 answer
  • why is the thermal conductivity of super insolation order of magnitude lower than the thermal conductivity of ordinary insulatio
    13·1 answer
  • Consider a sinusoidal oscillator consisting of an amplifier having a frequency-independent gain A (where A is positive) and a se
    6·1 answer
  • Which is an example of a passive solar energy system
    10·1 answer
  • PLZZ HELP
    14·2 answers
  • Please help been stuck on this for a couple minutes
    5·1 answer
  • Zachary finished an internship as a Software Quality Assurance Engineer. For which job is he best qualified?
    8·2 answers
  • What is the importance of the causal link<br> in work accidents?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!