I am writing this program for our activity, but I have Problem at the end line, because whenever I input 'Y' when asked do you want to solve another set, the do repeats but the statement "Do you want to try again is flashed along with the question "Which shape's mensuration would you like me to calculate?\nChoose one:". May I ask whats wrong with this?

#include<iostream>
#include<math.h>

using namespace std;

int main (void)

char again;

do
{

cout<<"Which shape's mensuration would you like me to calculate?\nChoose one: \n\ncircle\nrectangle\nisoceles rectangle\nsquare\n\nEnter here(in lowercase):";

string shape;
getline(cin, shape);

if(shape=="circle"){
    int radius;
    cout<<"Enter the radius of the circle: ";
    cin>>radius;
    cout<<"\nThe area of the circle is: "<<3.142 * (radius * radius) <<endl;
    cout<<"The circumference of the circle is: "<<(2 * 3.142) * radius <<endl;
    }
else if(shape== "rectangle"){
    int width, length;
    cout<<"Enter the width of the rectangle: ";
    cin>>width;
    cout<<"Enter the length of the rectangle: ";
    cin>>length;
    cout<<"\nThe area of the rectangle is: "<<length * width<<endl;
    cout<<"The perimeter of the rectangle is: "<<2*(length + width)<<endl;
    }
else if(shape == "isoceles rectangle"){
    int base, side, height;
    cout<<"Enter the base length of the Isoceles Rectangle: ";
    cin>>base;
    cout<<"Enter the side length of the Isoceles Rectangle: ";
    cin>>side;
    cout<<"Enter the height of the Isoceles Rectangle: ";
    cin>>height;
    cout<<"\nThe perimeter of the Isoceles Rectangle: "<<(2* side) + base<<endl;
    cout<<"The volume of the Isoceles Rectangle: "<< base * height * 0.5<<endl;
    }   
else if(shape == "square"){
    int length;
    cout<<"Enter the side length of the square: ";
    cin>>length;
    cout<<"\nThe perimeter of the square: "<<4*length<<endl;
    cout<<"The area of the square: "<< length * length<<endl;


    }

cout << "\nDo you want to solve another set? [Y/N]:";
cin >> again;

}

while (again == 'Y' || again == 'y');
cout << "\nThank you!";


return 0;

Straight after line 49, flush the input stream.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.