Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,075 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,600 people online right now. Registration is fast and FREE... Join Now!




C++ Program Help

 
Reply to this topicStart new topic

C++ Program Help, ItemMaker Program help?

LoganLooker
14 Apr, 2008 - 12:46 PM
Post #1

New D.I.C Head
*

Joined: 1 Feb, 2007
Posts: 38


My Contributions
CODE
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    
    int weapnum;
    char yn[3];
    
    // Start of Sig
    cout << & #34;|===========================================================================
==|" << endl;
    cout << "|                                                                             |" << endl;
    cout << "|                     Welcome to FEVERSTUDIOS RPG ItemMaker!                  |" << endl;
    cout << "|                                                                             |" << endl;
    cout << & #34;|===========================================================================
==|" << endl;
    cout << "|                                                                             |" << endl;
    cout << "|         Use this program to help you create items for your RPG games!       |" << endl;
    cout << "|                                                                             |" << endl;
    cout << & #34;|===========================================================================
==|" << endl;
    cout << "" << endl;
    // End of Sig
    
    system("PAUSE");
    
    // Start of Item Genre List
    cout << "Here is the list of items to pick from" << endl;
    cout << "1. Swords" << endl;
    cout << "2. Battle Axes" << endl;
    cout << "3. Daggers" << endl;
    cout << "4. 2 Handed Weapons" << endl;
    cout << "5. Godly Weapons" << endl;
    cout << "6. Staffs" << endl;
    cout << "7. Admin Weapons" << endl;
    system("pause");
    // End of Item Genre List
    
    // Start ItemMaker Directions
    cout << "In the next step please press the number that is next to your Item Genre" << endl;
    cout << "" << endl;
    system("pause");
    
    // Start of ItemMaker
    cout << "What type of item do you want to make?" << endl;
    cin >> weapnum;
    
    cout << "Are you sure this is the correct number?" << weapnum;
    cin >> yn;
    
    if( yn == yes || yn == y ) {
    system("pause");
    }
    
    system("PAUSE");
    return EXIT_SUCCESS;
}


Ok, so now that you have seen my code I need to know how I can get a person to answer yes or no like here.

CODE
   cout << "Are you sure this is the correct number?" << weapnum;
    cin >> yn;
    
    if( yn == yes || yn == y ) {
    system("pause");
    }


Can someone tell me what I'm doing wrong I have seemed to mess this up somehow? What I want this program todo is, Have a user enter their ItemGenre (Sword, Battle Axe, Staff etc...) then I want the program to ask if this is the right number? and if they type yes or y then I want it to run a set of code for example it generates a Sword name and stats.

Thanks in advance.
User is offlineProfile CardPM
+Quote Post

gabehabe
RE: C++ Program Help
14 Apr, 2008 - 01:24 PM
Post #2

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,522



Thanked: 96 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
Why store yn as a char array? You could just save it as a single char, and even if the user types yes, it will only read the first character.

As for the input of yn, it's because you need to write the evaluations like 'y' in your if statement.
Look at this:
cpp

cout << "Are you sure this is the correct number?" << weapnum;
cin >> yn;

if( yn == 'Y' || yn == 'y' ) { //checks for y and Y
system("pause");
}


Hope this helps smile.gif
User is offlineProfile CardPM
+Quote Post

LoganLooker
RE: C++ Program Help
14 Apr, 2008 - 02:00 PM
Post #3

New D.I.C Head
*

Joined: 1 Feb, 2007
Posts: 38


My Contributions
Thanks man smile.gif
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 07:19PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month