Hellp!

This is a discussion on Hellp! within the C++ Programming forums, part of the General Programming Boards category; Why don't that work? //***************************************** //code copyright to Jeff Cook, 2002. //original text-based game. //May 30, 2002 - //***************************************** #include ...

  1. #1
    Unregistered
    Guest

    Hellp!

    Why don't that work?


    //*****************************************
    //code copyright to Jeff Cook, 2002.
    //original text-based game.
    //May 30, 2002 -
    //*****************************************
    #include <iostream.h>
    #include <stdlib.h>

    char yon;
    int choice1;
    int acorns=200;

    int main()
    {
    cout<<"\nWelcome to Sugi the Hipmunk's game. Would you care to give it a spin? (Y or N)\n"; //Welcomes player and asks if they would like to play.
    cin>>yon;
    if(yon=='y'||'Y') //If the player hits Y for Yes, they will begin play.
    {
    cout<<"Great! Let's begin.\n";
    cout<<"\nAs Sugi begins his happening adventure, he encounters none other than shopkeeper Harris.\n";
    cout<<"You've been offered some goods. Do you:";
    cout<<"\n1. Buy them for 20 acorns?\n2.Do nothing and walk away?\n3.Kill the shopkeeper and blame it on your blanky.\n";
    cin>>choice1;
    if(choice1==1)
    {
    acorns-20;
    cout<<"You have: "acorns" acorns";
    }
    if(choice1==2)
    {
    cout<<"OK, you have walked away. No acorns have been subtracted.";
    }
    if(choice1==3)
    {
    cout<<"MURDER!";
    return 0;
    }
    }

    if(yon=='n'||'N') //When player hits N for No, kill the program.
    {
    cout<<"Goodbye.";
    system("PAUSE");
    return 0;
    }
    }

  2. #2
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    acorns -= 20;
    instead of
    acorns-20;

    [EDIT]
    Also,

    cout<<"You have: " << acorns << " acorns";
    [/EDIT]
    Last edited by Mario; 05-30-2002 at 11:55 AM.
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

  3. #3
    Unregistered
    Guest
    Still get the error. Parse error before string constant on line 27.

  4. #4
    Registered User Mario's Avatar
    Join Date
    May 2002
    Posts
    317
    yes. I just edited my message
    Regards,
    Mario Figueiredo
    Using Borland C++ Builder 5

    Read the Tao of Programming
    This advise was brought to you by the Comitee for a Service Packless World

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hellp My Code!!!! Doesnt Work!!
    By icefire99 in forum C++ Programming
    Replies: 4
    Last Post: 04-24-2007, 06:36 AM
  2. HEllp!!! Please!!!
    By *Michelle* in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 12-21-2002, 07:53 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21