Question: Write a program that determines the season based on the month. The program prompts a user to enter a month ( 1 - 1 2

Write a program that determines the season based on the month. The program prompts a user to enter a month (1-12) and then prints the season of that month. That is if that month is in spring, summer fall or winter. The program must also check if a valid month was entered. For simplicity, assume: 1-3: spring, 4-6: summer, 7-9 fall, 10-12 winter.
int main()
{
int
month;
do
{
cout << "Month: ";
cin >> month;
}
do
(month <1
|| month >12
);
switch
(month)
{
case 1:
case 2:
case 3:
cout << "Spring
";
break;
case 4:
case 5:
case 6:
cout << "Summer
";
break;
case 7:
case 8:
case 9:
cout << "Fall
";
break;
case 10:
case 11:
case 12:
cout << "Winter
";
break;
}
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!