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
When a circuit has more resistance, what happens to current flow ?
zloy xaker [14]
The relationship between resistance and the area of the cross section of a wire is inversely proportional . When resistance is increased in a circuit , for example by adding more electrical components , the current decreases as a result.
6 0
3 years ago
A segment of four-lane freeway (two lanes in each direction) has a 3% upgrade that is 1500 ft long followed by a 1000-ft 4% upgr
Dennis_Churaev [7]

Answer:

The level of service of of compound grade freeway is LOSB.

Explanation:

Find the provided attachments for explanation

3 0
3 years ago
Which of the following tape measure techniques can be used to achieve accurate measurements? Choose all that apply.
zepelin [54]

Answer: Pull.

Because it's all about height width and Breadth!

5 0
3 years ago
1. A glass window of width W = 1 m and height H = 2 m is 5 mm thick and has a thermal conductivity of kg = 1.4 W/m*K. If the inn
emmasim [6.3K]

Answer:

1. \dot Q=19600\ W

2. \dot Q=120\ W

Explanation:

1.

Given:

  • height of the window pane, h=2\ m
  • width of the window pane, w=1\ m
  • thickness of the pane, t=5\ mm= 0.005\ m
  • thermal conductivity of the glass pane, k_g=1.4\ W.m^{-1}.K^{-1}
  • temperature of the inner surface, T_i=15^{\circ}C
  • temperature of the outer surface, T_o=-20^{\circ}C

<u>According to the Fourier's law the rate of heat transfer is given as:</u>

\dot Q=k_g.A.\frac{dT}{dx}

here:

A = area through which the heat transfer occurs = 2\times 1=2\ m^2

dT = temperature difference across the thickness of the surface = 35^{\circ}C

dx = t = thickness normal to the surface = 0.005\ m

\dot Q=1.4\times 2\times \frac{35}{0.005}

\dot Q=19600\ W

2.

  • air spacing between two glass panes, dx=0.01\ m
  • area of each glass pane, A=2\times 1=2\ m^2
  • thermal conductivity of air, k_a=0.024\ W.m^{-1}.K^{-1}
  • temperature difference between the surfaces, dT=25^{\circ}C

<u>Assuming layered transfer of heat through the air and the air between the glasses is always still:</u>

\dot Q=k_a.A.\frac{dT}{dx}

\dot Q=0.024\times 2\times \frac{25}{0.01}

\dot Q=120\ W

5 0
3 years ago
50.38
klemol [59]

Answer:

International Building Code (IBC)

Explanation:

6 0
2 years ago
Other questions:
  • A stainless-steel specimen from the same material characterized up above, was formed into a rectangular cross-section of dimensi
    9·1 answer
  • A harmonic oscillator with spring constant, k, and mass, m, loses 3 quanta of energy, leading to the emission of a photon.
    13·1 answer
  • A company that produces footballs uses a proprietary mixture of ideal gases to inflate their footballs. If the temperature of 23
    11·1 answer
  • When diagnosing engine noise, Technician A says a mechanical stethoscope may not be appropriate in pinpointing a squeaking drive
    14·1 answer
  • Consider a very long, cylindrical fin. The temperature of the fin at the tip and base are 25 °C and 50 °C, respectively. The dia
    14·1 answer
  • Digital leaders are people who __ others down a particular path.
    13·2 answers
  • A Rankine steam power plant is considered. Saturated water vapor enters a turbine at 8 MPa and exits at condenser at 10 kPa. The
    13·1 answer
  • Identify the different engineering activities/steps in the engineering design process for each steps,summarize in 1–3 sentences
    9·1 answer
  • NO SCAMS
    9·2 answers
  • What is the minimum clamp time for gluing a panel?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!