#include<iostream.h>
#include<conio.h>
class xyz
{
float l,b,a1,pi,r,a2;
public:
void switch();
};
void rectangle();
{
cout<<"\n enter the value of l=";
cin>>l;
cout<<"\n enter the value of b=";
cin>>b;
a1=l*b;
cout<<a1;
}
void circle();
{
pi=3.15;
cout<<"\n enter the value of r=";
cin>>r;
a2=pi*r*r;
cout<<a2;
}
void main()
{
int ch;
xyz k;
cout<<"press 1 for rectangle and press 2 for circle";
cin>>ch;
switch(ch);
{
case 1 :
k.rectangle();
break;
case 2:
k.circle();
break;
default:
cout<<"wrong choice";
}
getch();
}
I want to write a program with switch statements. It writes area of rectangle when we press 1 and area of circle when we press2 else prints wrong choice. plz write the corrected program.