Answer to Question #12189 in C# for Cherry blossom

Question #12189
In the game of scissors, paper, stone (or Jack N Poy or Pick) each of two players choose either scissors (code X),paper (code P) or stone (code S). If one chooses scissors and the other chooses stone then paper wins. If one chooses paper and the other scissors then scissors wins. If they both chooses the same then the result is tie. Read in two character codes corresponding to the object selected and then output either message ‘PLAYER 1 WINS’, ‘PLAYER 2 WINS’ or ‘TIE’. Use the output format below:
JACK N POY GAME
PLAYER 1 ENTER :<value and not code>
PLAYER 2 ENTER:<value and not code>

RESULT :<result>
1
Expert's answer
2012-07-26T08:53:36-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
& static void Main(string[] args)
& {
string again;
do
{
Console.WriteLine(&quot;Enter symbol for first player (scissors (code X),paper (code P) or stone (code S)):&quot;);
string player1, player2;
player1 = Console.ReadLine();
Console.WriteLine(&quot;Enter symbol for second player (scissors (code X),paper (code P) or stone (code S)):&quot;);
player2 = Console.ReadLine();
if (player2 == player1)
{
& Console.WriteLine(&quot;TIE&quot;);
}
else if ((player1 == &quot;S&quot; || player1 == &quot;s&quot;) && (player2 == &quot;X&quot; || player2 == &quot;x&quot;) ||
& (player1 == &quot;X&quot; || player1 == &quot;x&quot;) && (player2 == &quot;P&quot; || player2 == &quot;p&quot;) ||
& (player1 == &quot;P&quot; || player1 == &quot;p&quot;) && (player2 == &quot;S&quot; || player2 == &quot;s&quot;))
{
& Console.WriteLine(&quot;player number one win!&quot;);
}
else
{
& Console.WriteLine(&quot;player number two win!&quot;);
}
Console.WriteLine(&quot;Do you want play again? enter Y&quot;);
again = Console.ReadLine();
} while (again == &quot;Y&quot; || again == &quot;y&quot;);

& }
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS