Can you please help me? I'm not allowed to define any functions or use void which is why the entire code should only work inside int main(). I need help putting the codes in the functions int nDays (int monthNo, int year), string getNameOfMonth(int monthNo), and void displayCalendar(int yr, int start_day) inside int main() #include #include using namespace std; int nDays (int monthNo, int year) { switch(monthNo) { case 0: return (31); break; case 1: if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { return (29); break; } else { return (28); break; } case 2: return (31); break; case 3: return (30); break; case 4: return (31); break; case 5: return (30); break; case 6: return (31); break; case 7: return (31); break; case 8: return (30); break; case 9: return (31); break; case 10: return (30); break; case 11: return (31); break; } } string getNameOfMonth(int monthNo) { string monthSet[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; return (monthSet[monthNo]); } void displayCalendar(int yr, int start_day) { cout<<" Calendar - "< 6) { k = 0; cout<<"\n"; } } if (k) cout<<"\n"; start_day = k; } return; } int main() // need help putting the codes in three functions inside int main() { int yr, start_day; cout <<"Enter a calendar year to display? "; cin>>yr; cout <<" what is the new year's day? "; cin>>start_day; displayCalendar(yr, start_day); return 0; }
A bartleby expert gave me the code below but I need help putting everything inside int main() because I told them there can't be anything before int main().
Can you please help me? I'm not allowed to define any functions or use void which is why the entire code should only work inside int main().
I need help putting the codes in the functions int nDays (int monthNo, int year), string getNameOfMonth(int monthNo), and void displayCalendar(int yr, int start_day) inside int main()
#include<iostream>
#include<iomanip>
using namespace std;
int nDays (int monthNo, int year)
{
switch(monthNo)
{
case 0:
return (31);
break;
case 1:
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
{
return (29);
break;
}
else
{
return (28);
break;
}
case 2:
return (31);
break;
case 3:
return (30);
break;
case 4:
return (31);
break;
case 5:
return (30);
break;
case 6:
return (31);
break;
case 7:
return (31);
break;
case 8:
return (30);
break;
case 9:
return (31);
break;
case 10:
return (30);
break;
case 11:
return (31);
break;
}
}
string getNameOfMonth(int monthNo)
{
string monthSet[] = {"January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December"
};
return (monthSet[monthNo]);
}
void displayCalendar(int yr, int start_day)
{
cout<<" Calendar - "<<yr<<"\n\n";
int theDays;
for (int i = 0; i < 12; i++)
{
theDays = nDays (i, yr);
cout<<"\n ------------"<<getNameOfMonth (i).c_str()<<"-------------\n";
cout<<" Sun Mon Tue Wed Thu Fri Sat\n";
int k;
for (k = 0; k < start_day; k++)
cout<<" ";
for (int j = 1; j <= theDays; j++)
{
cout<<setw(5)<<j;
if (++k > 6)
{
k = 0;
cout<<"\n";
}
}
if (k)
cout<<"\n";
start_day = k;
}
return;
}
int main() // need help putting the codes in three functions inside int main()
{
int yr, start_day;
cout <<"Enter a calendar year to display? ";
cin>>yr;
cout <<" what is the new year's day? ";
cin>>start_day;
displayCalendar(yr, start_day);
return 0;
}
![](/static/compass_v2/shared-icons/check-mark.png)
Program description :
The functions,int nDays (int monthNo, int year), string getNameOfMonth(int monthNo), and void displayCalendar(int yr, int start_day) are removed from the given c++ program.
The main.cpp C++ program objective is to remove all the functions from the given program and write all the code inside the main function.
The program prompts to enter the year value and starting day of the year as integer values and then print the year calendar on the c++ console window.
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)