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
A 1-kW electric resistance heater submerged in 10-kg water is turned on and kept on for 15 min. During the process, 400 kJ of he
hichkok12 [17]

Answer:

ΔT=  11.94 °C

Explanation:

Given that

mass of water = 10 kh

Time t= 15 min

Heat lot from water = 400  KJ

Heat input to the water = 1  KW

Heat input the water= 1 x 15 x 60

                                =900 KJ

By heat balancing

Heat supply - heat rejected = Heat gain by water

As we know that heat capacity of water

C_p=4.187 \frac{KJ}{kg-K}

Q=mC_p\Delta T

Now by putting the values

900 - 400 = 10 x 4.187 x ΔT

So  rise in temperature of water ΔT=  11.94 °C

6 0
3 years ago
A labor-intensive process to manufacture a product has a fixed cost of $338,000 and a variable cost of $143 per unit. An automat
ozzi

Answer:

no of unit is 17941

Explanation:

given data

fixed cost = $338,000

variable cost = $143 per unit

fixed cost = $1,244,000  

variable cost = $92.50 per unit

solution

we consider here no of unit is = n

so here total cost of labor will be sum of fix and variable cost i.e

total cost of labor = $33800 + $143 n  ..........1

and

total cost of capital intensive  = $1,244,000 + $92.5 n   ..........2

so here in both we prefer cost of capital if cost of capital intensive less than cost of labor

$1,244,000 + $92.5 n  <  $33800 + $143 n

solve we get

n > \frac{906000}{50.5}

n > 17941

and

cost of producing less than selling cost so here

$1,244,000 + $92.5 n < 197 n

solve it we get

n > \frac{1244000}{104.5}  

n > 11904

so in both we get greatest no is 17941

so no of unit is 17941

3 0
3 years ago
Kinetic energy is defined as energy of an object in:
Murrr4er [49]

your answer is c. motion

5 0
3 years ago
Read 2 more answers
The annual inventory cost C for a manufacturer is given below, where Q is the order size when the inventory is replenished. Find
Nataly_w [17]

The change in annual cost when Q is increased from 340 to 341 is -1.23 and the instantaneous rate of change when Q = 340 is -1.25

<h3>How to find the Instantaneous rate of change?</h3>

The annual inventory cost C for a manufacturer is given as;

C = (1012000/Q) + 7.5Q

where Q is the order size when the inventory is replenished.

Now, the change in C can be calculated by evaluating the cost function at Q = 340 and Q = 341

Change in C = [1,012,000/341 + 7.5*341] - [1,012,000/340 + 7.5*340] ≈ -1.23

Instantaneous rate of change in C is first order derivative C':

C'(Q) = -1,012,000/(Q²) + 7.5

C'(340) = -1,012,000/(340²) + 7.5 ≈ -1.25

Read more about Instantaneous rate of change at; brainly.com/question/14666106

#SPJ1

8 0
1 year ago
جائت فكرة ربط الحواسيب لغرض نقل البيانات و مشاركتها و بعدها بفتره قصيره جائت إمكانية مشاركة الموارد بين الحواسيب صح ام خطأ​
melamori03 [73]

Answer:

بدلاً من ذلك يُشار إليه باسم مشاركة أو مشاركة شبكة ، الدليل المشترك هو دليل أو مجلد يمكن الوصول إليه من قبل العديد من المستخدمين على الشبكة. هذه هي الطريقة الأكثر شيوعًا للوصول إلى المعلومات ومشاركتها على شبكة محلية

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • Can anybody teach me how to make an app with flask and pygame together?​
    10·1 answer
  • Two AAA-size lithium batteries are connected in series in a flashlight. Each battery has 3.5 volt and 4- Amp-hour capacity. If t
    8·1 answer
  • Determine the minimum force P to prevent the 30 kg uniform rod AB from sliding. The contact surface at B is smooth, whereas the
    13·1 answer
  • Establishes general guidelines concerning licensing and vehicle
    10·2 answers
  • The technique of smoothing out joint compound on either side of a joint is known as which of the following
    14·1 answer
  • Three 1.83 in. diameter bolts are used to connect the axial member to the support in a double shear connection. The ultimate she
    8·1 answer
  • Determine the resistance of 100m of copper cable whose cross-sectional area is 1.5mm2​
    6·1 answer
  • What is the width of a professional football field?.
    5·1 answer
  • Write a SELECT statement that returns these four columns:
    14·1 answer
  • A +7.5% grade meets a horizontal grade on a section of a rural mountainous highway. If the length of the crest vertical curve fo
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!