Ask Question
24 June, 09:27

Write a statement that compares the values of score1 and score2 and takes the following actions. When score1 exceeds score2, the message "player1 wins" is printed to standard out. When score2 exceeds score1, the message "player2 wins" is printed to standard out. In each case, the variables player1Wins, player1Losses, player2Wins, and player2Losses, are incremented when appropriate. Finally, in the event of a tie, the message "tie" is printed and the variable tieCount is incremented.

+5
Answers (1)
  1. 24 June, 10:49
    0
    Following are the statement in the C+ + Programming Language.

    //check condition that score1 is greater than score2

    if (score1 > score2)

    {//print the message and brake line

    cout << "player1 wins" << endl;

    //increment in the variable by 1

    ++player1Wins;

    //increment in the variable by 1

    ++player2Losses;

    }

    //check condition when score2 is greater than score1

    else if (score2 > score1)

    { / /print the message and brake line

    cout << "player2 wins" << endl;

    //increment in the variable by 1

    ++player2Wins;

    //increment in the variable by 1

    ++player1Losses;

    }

    //otherwise

    else

    { / /print the message and brake line

    cout << "tie" << endl;

    //increment in the variable by 1

    ++tieCount;

    }

    Explanation:

    Following are the description of the program.

    In the statement, we check that the variable 'score1' is greater than 'score2' then, print message and brake line, then increment in the variables by 1 that is 'player1Wins' and 'player2Losses'. Again check that the variable 'score2' is greater than 'score1' then, print message and brake line, then increment in the variables by 1 that is 'player2Wins' and 'player1Losses'. Otherwise, print the following message and break line then, increment in the variable 'tieCount'
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a statement that compares the values of score1 and score2 and takes the following actions. When score1 exceeds score2, the message ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers