Guest User

Untitled

a guest
Jun 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int P1Num, P2Num, Sum;
  6.     cout << "Player 1, enter a number between 1 and 5: \n";
  7.     cin >> P1Num;
  8.     if (P1Num < 1 || P1Num > 5)
  9.     {
  10.         cout << "The value entered by player 1, " << P1Num << ", must be between 1 and 5. \n";
  11.     }
  12.     else
  13.     cout << "Player 2, enter a number between 1 and 5: \n";
  14.     cin >> P2Num;
  15.     if (P2Num < 1 || P2Num > 5)
  16.     {
  17.         cout << "The value entered by player 2, " << P2Num << ", must be between 1 and 5. \n";
  18.     }
  19.     else
  20.     Sum = P1Num + P2Num;
  21.     if (Sum % 2 == 0)
  22.     {
  23.         cout << "The sum of the two numbers is even; therefore, player 1 wins! \n";
  24.     }
  25.     else
  26.         cout << "The sum of the two numbers is odd; therefore, Player 2 wins! \n";
  27.  
  28. return 0;
  29. }
Add Comment
Please, Sign In to add comment