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.

LANGUAGE: JAVA

CHALLENGE:

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.

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,

3 Comments

  1. Mojo jojo on September 16, 2016 at 11:03 am

    if (score1 > score2) {
    cout << "player1 wins" < score1) {
    cout << "player2 wins" << endl;
    ++player2Wins;
    ++player1Losses;
    } else {
    cout << "tie" << endl;
    ++tieCount;
    }
    correct answer

    • Craco on September 28, 2016 at 10:27 pm

      Thats for C++ this is Java

  2. Tanis Stryderson on September 30, 2016 at 6:58 pm

    This works

    if (score1 > score2)
    {cout < score1)
    {cout << "player2 wins" << endl;
    player2Wins ++;
    player1Losses ++;}
    else
    {cout << "tie" << endl;
    tieCount++;}

Leave a Comment

You must be logged in to post a comment.