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<<“nn”;
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 Satn”;
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;
}
