Hi!
Obviously Im pretty new to this but I would really appreciate some help.
My assignment is to create a program with yes n no answers using if/else statements and char. So these I cannot change.
Program is supposed to ask the user if the weather is nice or not.
If yes print out: Lets have picnic
If n lets: Stay inside and read a book
And if anything else is put in its supposed to say: I dont understand.
First issue Im having is that the y/n gets printed out no matter what I do. . .
2nd issues is that everything works fine until I add the last else statement and then it wont run with out error code: expected unqualified- id before 'else'
I have search for awhile regarding if/else and char but unfortunately not finding any answers that fits for my assignment.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include <iostream>
using namespace std;
int main()
{
cout << "Is the weather nice? y/n"; // y/n gets printed out
char answer;
cin >> answer;
if (answer == 'y' || answer == 'Y')
{
cout << "Lets have a picknick!";
}
else //not working
{
cout << "Lets stay inside and read a book";
}
}
else
{
cout << "I dont understand!";
}
|
So if anyone can please help explain this to me, I would appreciate it!!!!