Question
C++ Given a number, calculate how many years into the future it is, and what date. Assume no leap years. For example: Please enter a
C++ Given a number, calculate how many years into the future it is, and what date. Assume no leap years. For example: Please enter a day of the year (0 to exit): 1 jan 1 Please enter a day of the year (0 to exit): 365 dec 31 Please enter a day of the year (0 to exit): 366 1 year jan 1 Please enter a day of the year (0 to exit): 0 Thanks for playing!
Here's what I have the first two outputs are fine then it goes off. #include #include using namespace std; int main() { const int MonthDays[] = {31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; const string MonthName[] = {"jan", "feb", "march", "apr", "may", "june", "july", "aug", "sept", "oct", "nov", "dec"}; string go_on = "yes"; int day; int month = 0; while (go_on == "yes") { cout << "Please enter a day of the year (0 to exit): "; cin >> day; cout<365) day=day%365; while (MonthDays[month] < day) month = (month + 1) %12; if(day<=1 ||day<=31) cout<31) cout < Output: Please enter a day of the year (0 to exit): 1 jan 1 Please enter a day of the year (0 to exit): 365 dec 31 Please enter a day of the year (0 to exit): 31 dec 31 Please enter a day of the year (0 to exit): 32 dec -302 Please enter a day of the year (0 to exit): 144 dec -190 Please enter a day of the year (0 to exit): 216 dec -118 Please enter a day of the year (0 to exit): 0 Thanks for playing! dec 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started