My teacher has assigned a program to use both if-else statements and switch statements, so we understand how to implement both. The program asked u
You can not use a double inside a switch. The documentation says:
switch ( expression )
case constant-expression : statement
[default : statement]
The expression must be of an integral type or of a class type for which there is an unambiguous conversion to integral type. Integral promotion is performed as described in Integral Promotions.
On a side note:
There are some compilers (like Clang 3.5.1) which are allowing the case x ... y as an extension to the C++ language. But that too is for an integral datatype. Something like
switch(x){
case 0:
cout << "Test1";
break;
case 0 ... 9:
cout << "Test2";
break;