24 untitled1.cpp
parse error before `{'
29 untitled1.cpp
case label `'D'' not within a switch statement
29 untitled1.cpp
confused by earlier errors, bailing out
20 untitled1.cpp
for each function it appears in.)
D: Here be the source
#include <iostream.h>
//Global Variables
//Players HP
int hp=40;
int str=7;
int def=2;
//Monsters HP
int monHP=45;
int monStr=6;
int monDef=2;
//Damage
int damage=str-monDef;
int monDamage=monStr-def;
int main(){
char input;
while(hp>0){
cout<<"A monster has appeared and begins to attack! What do you do?"<<endl;
cout<<"A - Attack"<<endl<<"D - Defend"<<endl;
switch input{
case 'A':
cout<<"You attack the monster for "<<damage<<endl;
cout<<"Monster attacks you for "<<monDamage<<endl;
break;
case 'D':
cout<<"You defend against the monsters attacks!"<<endl;
cout<<"Monster weakly attacks you for "<<mondamage-=2<<endl;
break;
/* case default:
cout<<"You entered an incorrect value! A or D only!";
break; */
}
cout<<"HP remaining : "<<hp<<endl;
cout<<"Monster HP remaining : "<<monHP<<endl;
system("PAUSE");
}
return 0;
}
Sorry for not being fully commented :'[
using namespace std;
after the #include statement; you can't access cout without using its namespace, so you either have to explicitly use it by using std::cout in place of cout, or by implicitly using it, such as with the aforementioned using namespace std; statement.