Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please format the following code into a header file, implementation file, and main file. USING C++ ***********PLEASE MAKE SURE THE CODE COMPILES*************** I am having

Please format the following code into a header file, implementation file, and main file. USING C++

***********PLEASE MAKE SURE THE CODE COMPILES*************** I am having issues putting this code into separate files. Please help

#include #include using namespace std;

class DayOfYear { public: static const int daysAtEndOfMonth[]; static const string monthName[]; void print(); void setDay(int day) { this->day = day; }

private: int day;

};

const int DayOfYear::daysAtEndOfMonth[] = { 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };

const string DayOfYear::monthName[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October",

"November", "December" };

//****************************************************

// DayOfYear::print. Convert and print day of year *

//****************************************************

void DayOfYear::print() { int month = 0; while (daysAtEndOfMonth[month] < day)

month = (month + 1) % 12;

// DaysAtEndOfMonth >= day if (month == 0) cout << "January " << day; else cout << DayOfYear::monthName[month] << " " << day - DayOfYear::daysAtEndOfMonth[month - 1]; } //=================================== Main Program ============================================== int main() { // Tell user what program does cout << "This program converts a day given by a number 1 through 365" << " into a month and a day."; // Get user input cout << " Enter a number: "; int day; cin >> day;

if (day < 0 || day > 365) { cout << "Invalid range for a day."; exit(1); } // Do computation and print result DayOfYear dy; dy.setDay(day); dy.print(); return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

What kind of problem is this? How do I know?

Answered: 1 week ago