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, 04.07.2019 12:10
On a average work day more than work place firs are reorted
Answers: 1
question
Engineering, 04.07.2019 18:10
Water at 55c flows across a flat plate whose surface temperature is held constant at 95c. if the temperature gradient at the plate's surface for a given value of x is 18 c/mm, find a) local heat transfer coefficient. b) heat flux
Answers: 3
question
Engineering, 04.07.2019 18:10
You are making beer. the first step is filling the glass carboy with the liquid wort. the internal diameter of the carboy is 15 in., and you wish to fill it up to a depth of 2 ft. if your wort is drawn from the kettle using a siphon process that flows at 3 gpm, how long will it take to fill?
Answers: 1
question
Engineering, 04.07.2019 18:10
True or false (explain) (110)[111] is a slip system in bcc metals . the {111} family in fcc contains 8 planes. resolved shear stress (rss) in single crystals is just related to the applied stress. critical resolved shear stress (crss) in single crystal metals is direct proportional to the number of defects in the structure
Answers: 2
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, 30.08.2021 23:40