subject
Engineering, 14.03.2020 05:18 myg21

Needs to be written in C++

Assuming that a year has 365 days, write a class named DayOfYear that takes an integer representing a day of the year and translates it to a string for output consisting of the month followed by day of the month. For example:

day 2 would be "January 2".
day 32 would be "February 1".
day 365 would be "December 31".

The class should have:

a constructor for the class which takes as a parameter an integer representing the day number of the year
an private integer member variable to store the parameter
a "getter" to return the value of the member variable
member function which overloads the stream extraction operator to print the day in month-day format.
static constants which will assist in the conversion from an integer to a month-day format, for example, a collection of month names and days in each month.
The DayOfYear class described above should have a second constructor that takes two parameters: a string representing a month name and an integer in the range 1 through 31 representing the day of the month. The constructor should then initialize the integer member of the class to represent the day specified by the month and day of month parameters. The constructor should terminate the program with an appropriate error message if the month name entered is invalid or if the number entered for a day is outside the range of days for the month given.

Add the following overloaded operators:

prefix and postfix ++ (increment) operators. These operators should modify the DayOfYear object so that it represents the next day. If the day is already the end of the year, then the new value of the object will represent the first day of the year.

prefix and posfix –– (decrement) operators. These operators should modify the DayOfYear object so that it represent the previous day. If the day is already the first day of the year, then the new value of the object will represent the last day of the year.

Demonstrate the class by writing a main program which shows the appropriate month-day dates for days numbered 15, 31, 59, 180, and 360.

Also in main, demonstrate the second constructor by displaying the appropriate day number for "January 1", "March 4", "July 27", and "December 31".

Demonstrate how the prefix –– operator works on the first date (January 1) and the prefix ++ operator works on the second date (March 4) above. To do this, using a single cout statement, show the original value of the object (in month-day format), the object using the prefix++ or –– operator, and the final value of the object on three separate lines. For example, to demonstrate the prefix –– on day 1, the output might look like:

Using day 1:
The original value: January 1
Using prefix–– : December 31
After prefix–– : December 31
Also demonstrate how the postfix version of the –– and ++ operators work by doing the same thing on the third (July 27) and fourth (December 31) dates above, respectively.

Finally demonstrate what happens when an invalid month/day combination (such as February 30) is entered using the second constructor.

ansver
Answers: 1

Another question on Engineering

question
Engineering, 03.07.2019 19:30
When using the ohmmeter function of a digital multimeter, the leads are placed in what position relative to the component being tested? a. parallel b. control c. series d. line
Answers: 3
question
Engineering, 04.07.2019 18:10
Aplate clutch has a single pair of mating friction surfaces 250-mm od by 175-mm id. the mean value of the coefficient of friction is 0.30, and the actuating force is 4 kn. a) find the maximum pressure and the torque capacity using the uniform-wear model. b) find the maximum pressure and the torque capacity using the uniform-pressure model.
Answers: 3
question
Engineering, 04.07.2019 18:10
The higher the astm grain size number, the finer the gran is. a)-true b)-false
Answers: 2
question
Engineering, 04.07.2019 18:10
An air compression refrigeration system is to have an air pressure of 100 psia in the brine tank and an allowable air temperature increase of 60°f for standard vapor compression cycle temperatures of 77 f entering the expansion cylinder and 14 f entering the compression cylinder, calculate the coefficient of performance a. 2.5 b 3.3 c. 4.0 d. 5.0
Answers: 3
You know the right answer?
Needs to be written in C++

Assuming that a year has 365 days, write a class named DayOfY...
Questions
question
Mathematics, 22.01.2020 07:31
question
English, 22.01.2020 08:31
question
Mathematics, 22.01.2020 08:31
question
Mathematics, 22.01.2020 08:31
Questions on the website: 13722367