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; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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;

}

Expert Solution
Step 1

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.

 

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education