Halloween Selection Solution

Alright, so i have to create a program which displays a halloween images, the following directions were given to me:

Create a program which will ask the user to enter one of the following
strings: Halloween or pretty flower. If the user types in Halloween, in
upper or lower case letters, the program should display a friendly
Halloween image. If the user enters pretty flower a different Halloween
image should display. If the user enters any other string, the program
should display something like “Happy Halloween! Or Trick or Treat!”
Search online for your Halloween ASCII art images.
Each line of the ASCII art image must be outputted as a separate line using
separate cout statements. **The “character may not be contained in the
output stream. You will need to change that character to a different
character such as „. If you would like to output a forward slash - \, the
output stream must contain two \\s next to each other. Only one of the two
forward slash characters will be displayed. Change the text color for each
image in the command prompt. You can find the code to do this on line.
Run the program three times inputting “Halloween”, “PRETTY flower” and
finally “C++ is great”.

So i made this program, and when i tried to build it, i had 102 errors,several were in the ASCII image, stating the components of these images were "undeclared identifiers" and i did not understand what i was doing wrong.

Can someone give me a basis to making the right solution?


First of all I don't know your solution because you didn't post it. If you did't do that, I can't see your logical part of creating the structure of the program and I can't help you.
//Halloween Selection.cpp - displays a halloween image or halloween celebratory remark depending on what the user inputs

#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using namespace std;

int main()

//declare variables
name = ""

//enter input
cout << "Enter Halloween or pretty flower: ";
cin (get, name);

//validate input
if (name == "HALLOWEEN" || "halloween" || "Halloween")
{ cout << @@@ << endl;endl
cout << @@@ << endl;
cout << @@@ H A P P Y << endl;
cout << @@@ << endl;
cout << @@@@@@@@@@@@@@@@@@@@@@ H A L L O W E E N << endl;
cout << @@@@@@@@@@@@@@@@@@@@@@@@@@ << endl;
cout << @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ << ;
cout << @@@@@@@@ @@@@@@@@@@@@@@@@ @@@@@@@@ << endl;
cout << @@@@@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@ << endl;
cout << @@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@ << endl;
cout << @@@@@@@@@@ @@@@ @@@@ @@@@@@@@@@ << endl;
cout << @@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@ << endl;
cout << @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@ << endl;
cout << @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ << endl;
cout << @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ << endl;
cout << @@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@ << endl;
cout << @@@@@@@@ @@ @@ @@ @@ @@ @@ @@ @ @@@@@@@@ << endl;
cout << @@@@@@@ @@@@@@@ << endl;
cout << @@@@@@ @@ @@ @@ @@ @@ @@ @ @@@@@@ << endl;
cout << @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ << endl;
cout << @@@@@@@@@@@@@@@@@@@@@@@@@@ << endl;
} cout << @@@@@@@@@@@@@@@@@@@@@@ << endl;

else if ( name == "pretty flower")
cout << .---. << endl;
cout << / \\ << endl;
cout << ---- _ | O O | _ --- << endl;
cout << \\ ~-. `. . / << endl;
cout << \\ ~-_> <_-~ / << endl;
cout << \\ / << endl;
cout << \\ / << endl;
cout << \\ / << endl;
cout << \\ / << endl;
cout << \\ / << endl;
cout << \\ / << endl;
cout << \\ \\ << endl;
cout << \\ \\ << endl;
cout << \\ \\ << endl;
cout << \\ \\ << endl;
cout << \\ l << endl;
cout << \\ / << endl;
cout << V << endl;

else
cout << "Happy Halloween! Or Trick or Treat!" << endl;

return 0;
}

The image is supposed to be in display, but it looks how it does because of the comment formatting
Last edited on
closed account (967L1hU5)
When you use "cout", make sure your using quotations. One example from your code would be:
cout << @@@@@@@@@@@@@@@@@@@@@@ H A L L O W E E N << endl;
Put quotes on what you want to output, like this:
cout << "@@@@@@@@@@@@@@@@@@@@@@ H A L L O W E E N" << endl;
In your case, do that for every line that has cout.
Next time use [code][/code] tags.

A few things :
As dallyO said, use quotes for strings.

name == "HALLOWEEN" || "halloween" || "Halloween" should be
name == "HALLOWEEN" || name == "halloween" || name == "Halloween"

Use {} blocks around if, else blocks, also you forgot an opening brace after main().

Declare type for the variable name.

Also you have a bunch of missing or misplaced tokens. Compiler errors should tell you where.

I also recommend : http://cplusplus.com/doc/tutorial/
Last edited on
The mistakes you do are so simple. I mean...to print on the screen a string using the cout is basic to know that you have to do it like that: cout<<"your_string";. First of all, you have to learn the basics of the language: the sintax of that flux, of the functions, the way you compare a constant char with a string pointer and so on. Don't try to make something very complex without having the knowledge about that.
Topic archived. No new replies allowed.