Guest User

Untitled

a guest
Jun 19th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 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. for (int i=1; i<=4; i++)
  43. while(playAgainCode != -1)
  44. {
  45.  
  46. Console.WriteLine("OK, {0}, Let's Go! Enter you GUESS. Enter either the number 1 or 100, {0}", name);
  47.  
  48. int players_number = int.Parse(Console.ReadLine());
  49.  
  50. // if (players_number == -1)
  51.  
  52. // {
  53.  
  54. // break;
  55.  
  56. // }
  57.  
  58. // Now get the computer's number;
  59.  
  60. Random rnd = new Random();
  61.  
  62. int computer_guess = rnd.Next(1, 100);
  63.  
  64. Console.WriteLine("Here is my number, {0}: {1}", name, computer_guess);
  65.  
  66.  
  67.  
  68. if (computer_guess < 50 && players_number == 1)
  69.  
  70. {
  71.  
  72. Console.WriteLine("Player WINS!!!");
  73. give_Advice(name, age);
  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.  
  94. }
  95.  
  96. //Console.WriteLine("Play again, {0} ?", name);
  97.  
  98. playAgainCode = int.Parse(Console.ReadLine());
  99.  
  100. Console.ReadLine();
  101. }
  102.  
  103.  
  104. }
  105.  
  106.  
  107.  
  108. static void give_Advice(string name, int age)
  109.  
  110. {
  111.  
  112. 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());
  113.  
  114. }
  115.  
  116. }
  117. }
Add Comment
Please, Sign In to add comment