Guest User

Untitled

a guest
Jun 19th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. using System;
  2.  
  3. namespace HelloWorld
  4.  
  5. {
  6.  
  7. public class Hello
  8.  
  9. {
  10.  
  11. static void Main()
  12.  
  13. {
  14.  
  15. Console.WriteLine("Welcome to the Online Gaming Forum!");
  16.  
  17. string name;
  18.  
  19. int age;
  20.  
  21. Console.Write("Enter your name: ");
  22.  
  23. name = Console.ReadLine();
  24.  
  25. Console.WriteLine("How old are you, {0}?", name);
  26.  
  27. age = int.Parse(Console.ReadLine());
  28.  
  29. Console.WriteLine("Let's play a game, {0}", name);
  30.  
  31. Console.WriteLine("I will guess a number between 1 and 100");
  32.  
  33. Console.WriteLine("All you need to do, {0}, is say whether my number is closer to 1 or 100", name);
  34.  
  35. Console.WriteLine("If you win, {0}, you will get a fabulous prize!", name);
  36.  
  37. int playAgainCode = 0;
  38.  
  39.  
  40.  
  41.  
  42. //for (int a = 10; a < 20; a = a + 1)
  43. while(playAgainCode !=-1)
  44. {
  45. Console.WriteLine("OK, {0}, Let's Go! Enter you GUESS. Enter either the number 1 or 100, {0}", name);
  46.  
  47. int players_number = int.Parse(Console.ReadLine());
  48.  
  49. // if (players_number == -1)
  50.  
  51. // {
  52.  
  53. // break;
  54.  
  55. // }
  56.  
  57. // Now get the computer's number;
  58.  
  59. Random rnd = new Random();
  60.  
  61. int computer_guess = rnd.Next(1, 100);
  62.  
  63. Console.WriteLine("Here is my number, {0}: {1}", name, computer_guess);
  64.  
  65.  
  66.  
  67. if (computer_guess < 50 && players_number == 1)
  68.  
  69. {
  70.  
  71. Console.WriteLine("Player WINS!!!");
  72. Console.WriteLine(name, age);
  73.  
  74.  
  75.  
  76. }
  77.  
  78. else if (computer_guess >= 50 && players_number == 100)
  79.  
  80. {
  81.  
  82. Console.WriteLine("Player WINS!!!");
  83.  
  84.  
  85.  
  86. }
  87.  
  88. else
  89.  
  90. {
  91.  
  92. Console.WriteLine("Player loses!!!");
  93. give_Advice(name, age);
  94.  
  95. }
  96.  
  97. Console.WriteLine("Play again, {0} ?", name);
  98.  
  99. playAgainCode = int.Parse(Console.ReadLine());
  100.  
  101. Console.ReadLine();
  102. }
  103. }
  104.  
  105.  
  106.  
  107. static void give_Advice(string name, int age)
  108.  
  109. {
  110.  
  111. Console.WriteLine("As to your Prize - Honestly, {0}, at the Sweet Age of {1}, you should know better than to believe vague promises...", name, age.ToString());
  112.  
  113. }
  114.  
  115.  
  116.  
  117. }
  118.  
  119. }
Add Comment
Please, Sign In to add comment