| | |
Have an error in my program
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jan 2005
Posts: 7
Reputation:
Solved Threads: 0
Ok, i know my program is probably all done incorrectly and thier are probably eaiser ways but, it works for me so.. I have an error and i cant find out what it is. Can anyone tell me?
C++ Syntax (Toggle Plain Text)
//Game Project 1 #include <iostream.h> #include <conio.h> #include <iomanip.h> #include <stdlib.h> main() { char weapon, head, chest, hands, legs, feet, name[21]; int health, money, answer, shop_answer, fight_answer, weapon_answer; int armor_answer, potion_answer; health = 100; money = 0; cout<<setw(40)<<"BLANK"<<endl; getch(); system("CLS"); //Clears the Screen cout<<"Enter a name: "; cin.get(name, 21); cin.ignore(30,'\n'); system("CLS"); //Clears the Screen { do { system("CLS"); //Clears the Screen cout<<setw(30)<<"---------"<<name<<"---------"<<endl; cout<<"\n"; cout<<"---WEAPON--- "<<endl; cout<<"Weapon = "<<weapon<<endl; cout<<"\n"; cout<<"---ARMOR--- "<<endl; cout<<"Head = "<<head<<endl; cout<<"Chest = "<<chest<<endl; cout<<"Hands = "<<hands<<endl; cout<<"Legs = "<<legs<<endl; cout<<"Feet = "<<feet<<endl; cout<<"\n"; cout<<"---ITEMS---"<<endl; cout<<"Health "<<health<<endl; cout<<"Money $"<<money<<endl; getch(); system("CLS"); //Clears the Screen cout<<"---What would you like to do?---\n"<<endl; cout<<"1) Shop\n"; cout<<"2) Fight\n"; cout<<"3) See Stats\n"; cout<<"Press 1, 2, or 3:\n "; cin>> answer; switch (answer) { case 1: system("CLS"); //Clears the Screen cout<<"---What would you like to buy?---\n"; cout<<"1) Weapons\n"; cout<<"2) Armor\n"; cout<<"3) Health Potions\n"; cout<<"Press 1, 2, or 3:\n "; cin>> shop_answer; case 2: system("CLS"); //Clears the Screen cout<<"---Who do you want to fight?---\n"; cout<<"1) A Man\n"; cout<<"2) A Bandit\n"; cout<<"3) A Knight\n"; cout<<"4) A Dragon\n"; cout<<"Press 1, 2, 3, or 4:\n "; cin>> fight_answer; switch (shop_answer) { case 1: system("CLS"); //Clears the Screen cout<<"---What type of Weapon do you want to buy?---\n"; cout<<"1) Sword\n"; cout<<"2) Bow\n"; cout<<"3) Mace\n"; cout<<"Press 1, 2, or 3:\n "; cin>> weapon_answer; case 2: system("CLS"); //Clears the Screen cout<<"---For what part of body?---\n"; cout<<"1) Head\n"; cout<<"2) Chest\n"; cout<<"3) Hands\n"; cout<<"4) Legs\n"; cout<<"5) Feet\n"; cout<<"Press 1, 2, 3, 4, or 5:\n "; cin>> armor_answer; case 3: system("CLS"); //Clears the Screen cout<<"---One potion costs 25 gold. are you sure you want to buy?\n"; cout<<"1) Yes\n"; cout<<"2) No\n"; cout<<"Press 1 or 2:\n "; cin>> potion_answer; switch (potion_answer) { case 2: answer = 3; ////////SPACE////////////SPACE//////////////SPACE////////////SPACE/////////// if ((potion_answer == 1) && (money >= 25)) { health = health - 20; money = money - 25; answer = 3; { if ((potion_answer == 1) && (!(money >= 25))) { cout<<"You do not have enough money!\n"; answer = 3; } }while (answer == 3); //Loop again if answer is equal to 3. } getch(); return 0; }
![]() |
Similar Threads
- Please correct the error in my program. When i run the program on turbo c++ 3,. (C++)
- Please find and correct the error in my c++ program. "Linker Error: Undefined symbol (C++)
- Please help me to find error in this program .I am trying to add data to a dynamic ar (C++)
- error in the program (C)
- Linker Error when program is run (Urgent help required Please") (C++)
- Error in c++ program (C++)
Other Threads in the C++ Forum
- Previous Thread: what is the best way to track segmentation fault errors
- Next Thread: why can't you use a switch statment with a string?
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news numbertoword output parameter pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






