int main()
{
double A,B,C,S,D;
char choice;
cout<<"Hello, I am HeronBot.\nMy purpose in life is to inaccurately compute area's of triangles for you.\nPlease input the lengths of the sides of your triangle.";
do
{
cout<<"\nSide 1: ";
cin>>A;
do
{
if(A <= 0)
{cout<<"\nLength of a side must be positive\n"<<"Retry Side 1: ";
cin>>A;
}}while(A<=0);
// ^^ that repeated a couple times and then the formula.
cout<<"\nWould you like to incorrectly find the area of another triangle?\n(Yes, No)"<<endl;
cin>>choice;
}while(choice = 'Yes');
return 0;
}
Whether I type Yes or No it loops over and over without waiting for new values for A etc. and just uses the values inputted the first time.
choice is a char. A single char. You can't stuff an entire word into it. And what doesn't get stuffed into it remains in the input stream.
Also, = is for assignment. == is for comparison. Pay attention to the warnings your compiler generates -- 'Yes' is not a valid character, and we indicate character literals by enclosing them in single quotes.
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
double A,B,C,S,D;
string choice;
cout<<"Hello, I am HeronBot.\nMy purpose in life is to inaccurately compute area's of triangles for you.\nPlease input the lengths of the sides of your triangle.";
do
{
cout<<"\nSide 1: ";
cin>>A;
do
{
if(A <= 0)
{cout<<"\nLength of a side must be positive\n"<<"Retry Side 1: ";
cin>>A;
}}while(A<=0);
// ^^ that repeated a couple times and then the formula.
cout<<"\nWould you like to incorrectly find the area of another triangle?\n(Yes, No)"<<endl;
cin>>choice;
}while(choice == "Yes");
return 0;
}