Guest User

Untitled

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