here's my code:
cin>>figure;
switch (figure)
{
case '1': //figure is circle
system("cls");
cout<<"input radius: ";
cin>>rad;
cout<<"\nsurface area of your circle is "<<pi*rad*rad;
break;
case '2': //figure is rectangle
system("cls");
cout<<"input length: ";
cin>>length;
cout<<"\ninput width: ";
cin>>width;
cout<<"\nsurface area of your rectangle is "<<length*width;
break;
}
1)when i input for example "12" at CIN>>FIGURE,the program goes to case1 then won't ask the user to input a radius and treats second digit,which is "2",as it's radius.
question: how can i solve this one?
2)the program exits immediately when the user enters a non-numeric value on an input that needs to be computed.
question:how can i make the program ask the user to input a new value instead of exiting?