0

The program is getting an infinite loop only if I enter a letter or any character that isn't an integer.

image

cout<<"\n *GEOMETRY CALCULATOR*\n"
    <<"\nto stop Anytime ENTER -1\n"
    <<endl;




cout<<"please choose"
    <<"\n1-6 choices given below:\n"<<endl
    <<"1:Circle\n"
    <<"2:Rectangle\n"
    <<"3:Triangle\n"
    <<"4:Parallellogram\n"
    <<"5:Trapezoid\n"
    <<"6:square\n"
    <<endl;
//welcome to the GEOMETRY CALCULATOR.
    int   choice;
    const float PI = 3.14159 ; 
    float area , circumference , diameter , perimeter , radius;  

cout<<"choose shape to calculate...\n";
cin>>choice;    
while(choice != -1)
{

    if(!(choice>=1 && choice<=6))
        cout<<"\nplease enter only 1-6\n"
        <<"------------------------\n"<<endl;
    //if the choice is not in the given choices
Remy Lebeau
  • 505,946
  • 29
  • 409
  • 696

0 Answers0