Answer to Question #156879 in C++ for Riola Sadtoi

Question #156879

Question Link: https://ibb.co/nPcFz0r

1
Expert's answer
2021-01-20T10:28:16-0500
#include <iostream>
using namespace std;
int main () {
    int year, month;
    cout << "Enter the month: "; cin >> month;
    cout << "Enter the year: "; cin >> year;
    switch(month) {
        case 1 : 
            cout << "January " << year << " has 31 days.";
            break;
        case 2 : 
            if (year % 4 == 0) {
                cout << "Febrauary " << year << " has 29 days.";
                break;
            }
            else {
                cout << "Febrauary " << year << " has 28 days.";
                break;
            }
        case 3 : 
            cout << "March " << year << " has 31 days.";
            break;
        case 4 : 
            cout << "April " << year << " has 30 days.";
            break;
        case 5 : 
            cout << "May " << year << " has 31 days.";
            break;
        case 6 : 
            cout << "June " << year << " has 30 days.";
            break;
        case 7 : 
            cout << "July " << year << " has 31 days.";
            break;
        case 8 : 
            cout << "August " << year << " has 31 days.";
            break;
        case 9 : 
            cout << "September " << year << " has 30 days.";
            break;
        case 10 : 
            cout << "Octobor " << year << " has 31 days.";
            break;
        case 11 : 
            cout << "November " << year << " has 30 days.";
            break;
        case 12 : 
            cout << "December " << year << " has 31 days.";
            break;
    }
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog