Switch Statment Programming Errors

#include<iostream>
using namespace std;
int main()
{
// declare variables
int first;
int second;
int answer;
char operation;

//user input
cout<<"Choose an operation:";
cin>>operation;
operation=toupper(operation);
switch (operation)
{
cout<<"enter the first number"<<"\n\n";
cin>>first;
cout<<"enter the second number"<<"\n\n";
cin>>second;

case "A":
{
answer= first + second;
break;
}
case "M":
{

answer= first * second;
break;
}
case "S":
{
if(first >= second)
answer=first - second;
else
answer=second - first;

}
case "D":
{
if(second>first)
answer=second / first;
else
answer=first/second;

}// end switch
else

cout<<answer<<endl;

}


system("pause");
return 0;
}
These are the errors that im getting please help
Error 1 error C2051: case expression not constant e:\new project\project 4\project 4\project 4\project 4.cpp 22
Error 2 error C2051: case expression not constant e:\new project\project 4\project 4\project 4\project 4.cpp 27
Error 3 error C2051: case expression not constant e:\new project\project 4\project 4\project 4\project 4.cpp 33
Error 4 error C2051: case expression not constant e:\new project\project 4\project 4\project 4\project 4.cpp 41
Error 5 error C2181: illegal else without matching if e:\new project\project 4\project 4\project 4\project 4.cpp 49
closed account (Dy7SLyTq)
code tags. you need to do case 'D', ie with single quotes, you can only have constants (and sometimes function calls) that arent strings in a casetest
Topic archived. No new replies allowed.