Answer to Question #272678 in C++ for Tim

Question #272678

Create a program that will make ask the user to input an integer then display the equivalent day of the week. 1 is Sunday, 2 is Monday and so on. If the inputted number is not within 1-7m output is ''Day is not available!''.


1
Expert's answer
2021-11-28T05:25:32-0500
#include <iostream>
using namespace std;

int main()
{
    int n;
    cout << "Enter day of the week: ";
    cin >> n;
    switch (n)
    {
    case 1:
        cout << "Monday\n";
        break;
    case 2:
        cout << "Tuesday\n";
        break;
    case 3:
        cout << "Wednesday\n";
        break;
    case 4:
        cout << "Thursday\n";
        break;
    case 5:
        cout << "Friday\n";
        break;
    case 6:
        cout << "Saturday\n";
        break;
    case 7:
        cout << "Sunday\n";
        break;
    default:
        cout << "Day is not available!\n";
        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
APPROVED BY CLIENTS