Guest User

Untitled

a guest
Jun 19th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. // csc.exe /t:exe /out:L:\cs_source\MyApplication.exe L:\cs_source\program1.cs
  2. using System;
  3. namespace HelloWorld
  4. {
  5. public class Hello
  6. {
  7. static void Main()
  8. {
  9. Console.WriteLine("Welcome to the Online Gaming Forum!");
  10. string name;
  11. int age;
  12. Console.Write("Enter your name: ");
  13. name = Console.ReadLine();
  14. Console.WriteLine("How old are you, {0}?", name);
  15. age = int.Parse(Console.ReadLine());
  16. Console.WriteLine("Let's play a game, {0}", name);
  17. Console.WriteLine("I will guess a number between 1 and 100");
  18. Console.WriteLine("All you need to do, {0}, is say whether my number is closer to 1 or 100", name);
  19. Console.WriteLine("If you win, {0}, you will get a fabulous prize!", name);
  20. int playAgainCode = 0;
  21.  
  22. //for (int i=0; i<=4; i++)
  23. while (playAgainCode != -1)
  24. {
  25. Console.WriteLine("OK, {0}, Let's Go! Enter you GUESS. Enter either the number 1 or 100, {0}", name);
  26. int players_number = int.Parse(Console.ReadLine());
  27. // if (players_number == -1)
  28. // {
  29. // break;
  30. // }
  31. // Now get the computer's number;
  32. Random rnd = new Random();
  33. int computer_guess = rnd.Next(1, 100);
  34. Console.WriteLine("Here is my number, {0}: {1}", name, computer_guess);
  35.  
  36. if (computer_guess < 50 && players_number == 1)
  37. {
  38. Console.WriteLine("Player WINS!!!");
  39. give_Advice(name, age)
  40. }
  41. else if (computer_guess >= 50 && players_number == 100)
  42. {
  43. Console.WriteLine("Player WINS!!!");
  44.  
  45.  
  46. }
  47. else
  48. {
  49. Console.WriteLine("Player loses!!!");
  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. }
Add Comment
Please, Sign In to add comment