Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int P1Num, P2Num, Sum;
- cout << "Player 1, enter a number between 1 and 5: \n";
- cin >> P1Num;
- if (P1Num < 1 || P1Num > 5)
- {
- cout << "The value entered by player 1, " << P1Num << ", must be between 1 and 5. \n";
- }
- else
- cout << "Player 2, enter a number between 1 and 5: \n";
- cin >> P2Num;
- if (P2Num < 1 || P2Num > 5)
- {
- cout << "The value entered by player 2, " << P2Num << ", must be between 1 and 5. \n";
- }
- else
- Sum = P1Num + P2Num;
- if (Sum % 2 == 0)
- {
- cout << "The sum of the two numbers is even; therefore, player 1 wins! \n";
- }
- else
- cout << "The sum of the two numbers is odd; therefore, Player 2 wins! \n";
- return 0;
- }
Add Comment
Please, Sign In to add comment