Skip to content
Permalink
ac14ca3c3f
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
26 lines (25 sloc) 699 Bytes
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int hp = 15;
int enemyattack = 5;
string a;
cout << "Alien has " << hp << " health, every time you type 'Hit' it will drop by " << enemyattack << ".\n" << endl;
string Yes = "Hit";
while(true) // While typing 'Hit' it will minus the enemy attack value
{
cin >> a;
if (a == Yes)
{
hp -= enemyattack;
cout << "Alien now has " << hp << "HP left.\n\n";
if (hp==0) // When there is no Hp loop will break
{
break;
}
}
}
cout << "You have killed an enemy alien!" << endl;
}