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 19:10
What is the major difference between thermoplastics and thermosetting plastics from the polymerization structure point of view?
Answers: 2
question
Engineering, 04.07.2019 19:20
Asimple speed reducer is composed of 2 spur gears. the pinion gear has a pitch diameter of 0.75" and 36 teeth while the driven gear has a pitch diameter of 4.0" and 192 teeth. a)-what is the diametral pitch of each gear? b)-if an electric motor rotating ccw at 3000 rpm is coupled to the pinion, what is the rotational speed of the driven gear? c)-if the torque delivered to the pinion is 1 n-m, what is the torque on the driven gear? d)-what is the power transmitted by the gear train?
Answers: 1
question
Engineering, 06.07.2019 03:10
List and describe the parts of boxford cnc milling machine with pictures?
Answers: 2
question
Engineering, 06.07.2019 04:10
An array of m-50 thermoelectric modules is installed on the exhaust of a sports car. each module has an effective seebeck coefficient of sp of 0.143 5vk and an internal electrical resistance of r.-4 ? in addition, : (15 points each module is of width w 60mm and contains n=100 pairs of semiconducting pellets. each pellet hasan overall length of 2l-5mm and a cross-sectional area as 1.2 x 10'm and is characterized by a thermal conductivity of kpl2w rnk. the hot side of each module is exposed to exhaust gases at·p650c with hia4ow rrk while the osite side of each module is cooled by pressurized water at surface) and 156 °c (at the cool surface). 11s c with h: -500w/m'k. the modules are wired n series and the load resistance is r d=400ohm .the module surface temperatures, t, and ts are 183 "c (at the hot surface and 156c (at the cool surface) a)-draw a schematic of this scenario and label all parts. a. b. if the induced current, i, is 0.15 amps, what is the total power (pa) for one module? c. what is the total power harvest from the exhaust with all 50 modules?
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, 10.10.2019 22:00
question
Mathematics, 10.10.2019 22:00
question
Mathematics, 10.10.2019 22:00
Questions on the website: 13722363