Write a program to display the months falling in a particular season ? Use enumerated list to store 12 months. Program should continue till user inputs N.
Spring - March to June; Summer - June to September; Autumn - September to December; and, Winter - December to March
I have done till the step given below. How should I proceed further. Please give hint or tell what should I do next to display months? Also, how to ensure that program continues until user inputs N. Please help. I am a beginner in c++.
1 2 3 4 5 6 7 8 9 10
#include <iostream>
usingnamespace std;
int main()
{
enum month{Jan,Feb,Mar,April,May,Jun,July,Aug,Sep,Oct,Nov,Dec};
month M;
return 0;
}
I admit I'm not sure I understand your assignment's requirements. It sounds like you are only asked to do a simple lookup? Or, is there any user input at all?
Enums start at zero by default; you want the first month to start at one:
I'm not convinced this is a correct answer to OP's question. It appears that he is being taught to use enum as a substitute for const/constexpr values.
The whole point of an enum is that you aren't supposed to care what the actual value is. The only time you should care is during serialization.
[edit] I don't see how the original assignment is supposed to teach this...