switch cases and numeric operators issue
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int currentYear = 2010;
string name;
int yearBorn;
int age;
cout<<"Enter your name: ";
cin>>name;
cout<<"Oh, what a nice name, "<<name<<"."<<endl;
cout<<"When were you born? ";
cin>>yearBorn;
age = currentYear - yearBorn;
cout<<"Oh, so you're "<<age<<" years old?"<<endl;
cin.get();cin.get();
string msg;
switch(age)
{
case (10):
msg = "Oh, you're just a little kid,,, How cute!";
break;
}
cout<<msg<<endl;
}
Program works fine, but i'd like the switch's case to work with numeric operators.
In the example I made so the case would only store that message if the entered age was 10, but i'd like to work as "< 10", so that message would be printed if the user's age was lower than 10. How could i make this switch case work with numeric operators?