I'm a beginner in programming and I am currently trying to code things myself and I encountered a question that tells me to let a user choose from number 1-12 and it will display the month it represents (ex. 1=January) using while and switch loops. I'm now so brain dead need help.
edit: it loops if I entered a wrong input like putting a or 99.
#include <iostream>
using namespace std;
int main()
{
int months = 0;
cout << "Enter a number from 1-12 (or Q to quit): " << endl;
cin >> months;
while (months != 'Q')
{
switch (months){
case 1:
cout << "January" << endl;
break;
case 2:
cout << "February"<< endl;
break;
case 3:
cout << "March" << endl;
break;
case 4:
cout << "April" << endl;
break;
case 5:
cout << "May" << endl;
break;
case 6:
cout << "June" << endl;
break;
case 7:
cout << "July" << endl;
break;
case 8:
cout << "August" << endl;
break;
case 9:
cout << "September" << endl;
break;
case 10:
cout << "October" << endl;
break;
case 11:
cout << "November" << endl;
break;
case 12:
cout << "December" << endl;
break;
default:
{
cout <<"You've entered an invalid response. Please only select from numbers 1- 12.\n";
break;
}
}
}
//I hve no idea what to do here
return 0;
}