Hello.
This program is a simple calculator. You cannot divide by 0, thus when you enter 0 for division it will ask you if you want to try again.
What I need it to do: when choice != 'y', I need the menu to repeat
The problem: on the first try when choice !='y' the menu repeats, but then on other tries when choice != 'y' -- the output is this
Enter your choice: /
Enter first operand: 10
Enter second operand: 0
I have a second bool but a second one probably isn't needed huh?
I don't want to use any breaks or goto
Thank you for looking!
while (second == 0 && lol)
{
cout<<"Division by zero is not possible \n";
cout<<"Do you want to try again? ";
cin>> yesno;
lol = true;
if (!( yesno == 'Y' || yesno == 'y'))
{
lol = false;
}
else
{
cout<<" Enter second operand: ";
cin>> second;
// isValid ;
}
}
if (second != 0)
{
total = first / second;
cout << first <<" / " << second << " is "<< total << endl;
}
} //end of (choice == '/')