float items;
cin >>items;
switch (items) {
case 0.0:
cout << "Radio";
break;
case 1.0:
cout << "Television";
break;
case 1.5:
cout << "VideoCamera";
break;
浮点数是不能进行switch的。你可以对items乘以10,转换为整数,再case
int t = items*10;
switch(t)
{
case 0:
...
case 10:
...
case 15:
...
}
case 后面跟整数或者char。