Typhus
06-08-2006, 12:39 AM
Ok, I tried compiling this. My goal is this:
Please enter a number:
Please enter a second number:
The sum of the two numbers is:
Would you like to add again? ( Y = Yes, N - No ):
So I tried using a boolean variable to determine weither the loop go's off. So I get a compiler problems.
CODE BELOW
#include <iostream>
#include <string>
using namespace std;
int main()
{
double add1 = 0;
double add2 = 0;
double answer = 0;
int menu_answer;
bool menu_loop = true;
do
{
bool menu_loop = true;
cout << "Please enter a number: ";
cin >> add1;
cout << "Please enter a second number: ";
cin >> add2;
cout << "The sum of the two numbers is " << ( add1 + add2 ) << "\n";
cout << "Would you like to add again? ( Y = Yes, N = No )\n";
cin >> menu_answer;
if( menu_answer = Y)
{
menu_loop = true;
}
else if(menu_answer = N)
{
menu_loop = false;
}
while( menu_loop = true ); //
}
system("PAUSE");
return EXIT_SUCCESS;
}
Please enter a number:
Please enter a second number:
The sum of the two numbers is:
Would you like to add again? ( Y = Yes, N - No ):
So I tried using a boolean variable to determine weither the loop go's off. So I get a compiler problems.
CODE BELOW
#include <iostream>
#include <string>
using namespace std;
int main()
{
double add1 = 0;
double add2 = 0;
double answer = 0;
int menu_answer;
bool menu_loop = true;
do
{
bool menu_loop = true;
cout << "Please enter a number: ";
cin >> add1;
cout << "Please enter a second number: ";
cin >> add2;
cout << "The sum of the two numbers is " << ( add1 + add2 ) << "\n";
cout << "Would you like to add again? ( Y = Yes, N = No )\n";
cin >> menu_answer;
if( menu_answer = Y)
{
menu_loop = true;
}
else if(menu_answer = N)
{
menu_loop = false;
}
while( menu_loop = true ); //
}
system("PAUSE");
return EXIT_SUCCESS;
}