Guest User

Untitled

a guest
Jun 19th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. // csc.exe /t:exe /out:L:\cs_source\MyApplication.exe L:\cs_source\program1.cs
  2.  
  3. using System;
  4.  
  5. namespace HelloWorld
  6.  
  7. {
  8.  
  9. public class Hello
  10.  
  11. {
  12.  
  13. static void Main()
  14.  
  15. {
  16.  
  17. Console.WriteLine("Welcome to the Online Gaming Forum!");
  18.  
  19. string name;
  20.  
  21. int age;
  22.  
  23. Console.Write("Enter your name: ");
  24.  
  25. name = Console.ReadLine();
  26.  
  27. Console.WriteLine("How old are you, {0}?", name);
  28.  
  29. age = int.Parse(Console.ReadLine());
  30.  
  31. Console.WriteLine("Let's play a game, {0}", name);
  32.  
  33. Console.WriteLine("I will guess a number between 1 and 100");
  34.  
  35. Console.WriteLine("All you need to do, {0}, is say whether my number is closer to 1 or 100", name);
  36.  
  37. Console.WriteLine("If you win, {0}, you will get a fabulous prize!", name);
  38.  
  39. int playAgainCode = 0;
  40.  
  41.  
  42.  
  43. //for (int i = 0; i < 5; i++)
  44. While (playAgainCode != -1)
  45. {
  46.  
  47. Console.WriteLine("OK, {0}, Let's Go! Enter you GUESS. Enter either the number 1 or 100, {0}", name);
  48.  
  49. int players_number = int.Parse(Console.ReadLine());
  50.  
  51. // if (players_number == -1)
  52.  
  53. // {
  54.  
  55. // break;
  56.  
  57. // }
  58.  
  59. // Now get the computer's number;
  60.  
  61. Random rnd = new Random();
  62.  
  63. int computer_guess = rnd.Next(1, 100);
  64.  
  65. Console.WriteLine("Here is my number, {0}: {1}", name, computer_guess);
  66.  
  67.  
  68.  
  69. if (computer_guess < 50 && players_number == 1)
  70.  
  71. {
  72.  
  73. Console.WriteLine("Player WINS!!!");
  74. give_Advice(name, age);
  75.  
  76.  
  77. }
  78.  
  79. else if (computer_guess >= 50 && players_number == 100)
  80.  
  81. {
  82.  
  83. Console.WriteLine("Player WINS!!!");
  84. give_Advice(name, age);
  85.  
  86.  
  87. }
  88.  
  89. else
  90.  
  91. {
  92.  
  93. Console.WriteLine("Player loses!!!");
  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