I wrote a program that implements a simple calculator. However, it does not compile. The compiler says that there are 22 errors, and I don't know why.
Desired behavior:
- Asks user about the desired operation
- Asks user about the parameters
- Outputs result
Specific problem or error:
Compilation errors at any occurrence of cin
,cout
, endl
, case
and break
Minimal, Complete, and Verifiable example:
#include <iostream>
int main()
{
float area, r, l, h, b;
int choice;
cout<<"\n area of?";
cout<<"\n[1]square \n[2]rectangle \n[3]circle \n[4]triangle"<<endl;
cin>>choice;
switch(choice);
{
case 1:
cout<<"enter length"<<endl;
cin>>l;
area=l*l;
cout<<area<<endl;
break;
case 2:
cout<<"enter height"<<endl;
cin>>h;
cout<<"enter length"<<endl;
cin>>l;
area=l*h;
cout<<area<<endl;
break;
case 3:
cout<<"enter radius"<<endl;
cin>>r;
area=r*r*3.14;
cout<<area<<endl;
break;
case 4:
cout<<"enter height"<<endl;
cin>>h;
cout<<"enter breadth"<<endl;
cin>>b;
area=h*b*0.5;
cout<<area<<endl;
break;
}
return 0;
}