Guest User

Untitled

a guest
Jun 19th, 2018
109
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. namespace HelloWorld
  3. {
  4. public class Hello
  5. {
  6. static void Main()
  7. {
  8. Console.WriteLine("Welcome to the Online Gaming Forum!");
  9. string name;
  10. int age;
  11. Console.Write("Enter your name: ");
  12. name = Console.ReadLine();
  13. Console.WriteLine("How old are you, {0}?", name);
  14. age = int.Parse(Console.ReadLine());
  15. Console.WriteLine("Let's play a game, {0}", name);
  16. Console.WriteLine("I will guess a number between 1 and 100");
  17. Console.WriteLine("All you need to do, {0}, is say whether my number is closer to 1 or 100", name);
  18. Console.WriteLine("If you win, {0}, you will get a fabulous prize!", name);
  19. int playAgainCode = 0;
  20.  
  21. // for (int i=1; i<=4; i++)
  22. while(playAgainCode !=-1)
  23. {
  24. Console.WriteLine("OK, {0}, Let's Go! Enter you GUESS. Enter either the number 1 or 100, {0}", name);
  25. int players_number = int.Parse(Console.ReadLine());
  26. // if (players_number == -1)
  27. // {
  28. // break;
  29. // }
  30. // Now get the computer's number;
  31. Random rnd = new Random();
  32. int computer_guess = rnd.Next(1, 100);
  33. Console.WriteLine("Here is my number, {0}: {1}", name, computer_guess);
  34.  
  35. if (computer_guess < 50 && players_number == 1)
  36. {
  37. Console.WriteLine("Player WINS!!!");
  38.  
  39. }
  40. else if (computer_guess >= 50 && players_number == 100)
  41. {
  42. Console.WriteLine("Player WINS!!!");
  43.  
  44. }
  45. else
  46. {
  47. Console.WriteLine("Player loses!!!");
  48. give_Advice(name, age);
  49. }
  50. }
  51. Console.WriteLine("Play again, {0} ?", name);
  52. playAgainCode = int.Parse(Console.ReadLine());
  53. Console.ReadLine();
  54.  
  55. }
  56.  
  57. static void give_Advice(string name, int age)
  58. {
  59. 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());
  60. }
  61.  
  62.  
  63. }
  64. }
Add Comment
Please, Sign In to add comment