#include %26lt;iostream%26gt;
using namespace std;
void gah();
int main(void)
{
gah();
system("pause");
return 0;
}
void gah()
{
int answer1, answer2;
int counter=0;
cout %26lt;%26lt;" Please choose two landmarks" %26lt;%26lt; endl;
cout %26lt;%26lt; " 1. Millenium Park" %26lt;%26lt; endl %26lt;%26lt; "2. Statue of Liberty" %26lt;%26lt; endl %26lt;%26lt; "3. Grand Canyon" %26lt;%26lt; endl;
cin %26gt;%26gt; answer1 %26gt;%26gt; answer2;
if(answer1 == '1' %26amp;%26amp; answer2 == '2');
{
cout %26lt;%26lt; " gahhh " %26lt;%26lt; endl;
}
if(answer1 == '1' %26amp;%26amp; answer2 == '3');
{
cout %26lt;%26lt; "lah" %26lt;%26lt; endl;
}
if (answer1 == '2' %26amp;%26amp; answer2 == '3');
{
cout %26lt;%26lt; " heh" %26lt;%26lt; endl;
}
}
I need this c++ program to display one distance and time for the two places but it displays all three :(?
That is because you are calling the variables by a string or char type in the if statements. It should be
if(answer1 == 1 %26amp;%26amp; answer2 == 2)
{
cout %26lt;%26lt; "gahhh" %26gt;%26gt; endl;
}
also, the semi-colon does not need to go after the if parameters because if is being treated like a function with brackets.
When you use ' ' for a value, you are saying it is a char or string. Int values do not need them.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment