Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

C++ getting the month and day from a day of the year?

I formed the question weird.. but this is the problem:

"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 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 constructor for the class should take as parameter an integer representing the day of

the year, and the class should have a member function print() that prints the day in the

month-day format. The class should have an integer member variable to represent the day,

and should have static member variables of type string to assist in the translation from

the integer format to the month–day format.

Test your class by inputting various integers representing days and printing out their representation

in the month–day format."

I created an object for each month thinking that i could use a pointer the find it but ive gotten stuck. If u have coding u can help me with that would be awesome but an explanation of how i could pass an integer to the classes (or if i just need 1 class) how i could use that integer to find the month and day associated with that day

1 Answer

Relevance
  • 9 years ago
    Favorite Answer

    keep trying until u get it

    Source(s): experience
Still have questions? Get your answers by asking now.