Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Helloworld
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string ans = "";
  10. int count = 0;
  11. int count1 = 0;
  12.  
  13. Console.WriteLine("Welcome to RPS game");
  14.  
  15. while (ans != "NO")
  16. {
  17. Console.WriteLine("Select any one:\n1->ROCK\n2->PAPER\n3->SCISSOR");
  18. string[] choices = new string[3] { "ROCK", "PAPER", "SCISSOR" };
  19. Random rnd = new Random();
  20. int n = rnd.Next(0, 3);
  21. Console.WriteLine("Enter your choice:");
  22. string user = Console.ReadLine().ToUpper();
  23. Console.WriteLine("Computer:" + choices[n]);
  24.  
  25. if (user == "ROCK" && choices[n] == "SCISSOR")
  26. {
  27. Console.WriteLine("User wins");
  28. count += 1;
  29. }
  30. else if (user == "ROCK" && choices[n] == "PAPER")
  31. {
  32. Console.WriteLine("Computer wins");
  33. count1 += 1;
  34. }
  35. else if (user == "PAPER" && choices[n] == "ROCK")
  36. {
  37. Console.WriteLine("User wins");
  38. count += 1;
  39. }
  40. else if (user == "PAPER" && choices[n] == "SCISSOR")
  41. {
  42. Console.WriteLine("Computer Wins");
  43. count1 += 1;
  44. }
  45. else if (user == "SCISSOR" && choices[n] == "ROCK")
  46. {
  47. Console.WriteLine("Computer Wins");
  48. count1 += 1;
  49. }
  50. else if (user == "SCISSOR" && choices[n] == "PAPER")
  51. {
  52. Console.WriteLine("User wins");
  53. count += 1;
  54. }
  55. else
  56. {
  57. Console.WriteLine("Same choices");
  58. }
  59. Console.WriteLine("Do u want to continue(YES/NO):");
  60. ans = Console.ReadLine().ToUpper();
  61. Console.WriteLine("---------------------------------------");
  62. }
  63. Console.WriteLine("User wins " + count + " times");
  64. Console.WriteLine("Computer wins " + count1 + " times");
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement