Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int _playerLife = 100, playerLifeDecrease, i;
  8.  
  9. //loop{
  10. // display the player health
  11. // ask how much they would like to reduce the health by
  12. // print out the reduced health
  13. // if health <= 0 print("Early exit")
  14. // break out of the loop
  15. // if the player has looped through 10 times and still health remaining,
  16. // print("All 10 questions asked, life remaining")
  17. // Also check if i = 10 AND if there is any life remaining, if not
  18. // display messaging saying 10 questions asked but no life remaining
  19. //}
  20.  
  21.  
  22.  
  23. for (i = 0; i < 10; i++){
  24.  
  25. // display health
  26. cout << "Player HP: " << _playerLife << endl;
  27.  
  28. // ask how much to reduce by and print
  29. cout << "How much should we decrease the player health by?" << endl;
  30. cin >> playerLifeDecrease;
  31. _playerLife -= playerLifeDecrease;
  32.  
  33. // after 10 loops through check how the remaining life score
  34. if (i == 9){
  35. cout << "Player HP: " << _playerLife << endl;
  36. cout << "All 10 questions have been asked and the player ";
  37. if (_playerLife > 0){
  38. cout << "still has life remaining" << endl;
  39. break;
  40. }
  41.  
  42. else{
  43. cout << "has no life remaining" << endl;
  44. break;
  45. }
  46.  
  47. }
  48.  
  49. // if health <= 0
  50. if (_playerLife <= 0){
  51. cout << "Player HP: " << _playerLife << endl;
  52. cout << "Early exit" << endl;
  53. break;
  54. }
  55.  
  56.  
  57.  
  58. }
  59.  
  60.  
  61.  
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement