Guest User

Untitled

a guest
Jun 19th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 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 < 5; i++)
  23. while (playAgainCode != -1)
  24. {
  25.  
  26. Console.WriteLine("OK, {0}, Let's Go! Enter you GUESS. Enter either the number 1 or 100, {0}", name);
  27. int players_number = int.Parse(Console.ReadLine());
  28. // if (players_number == -1)
  29. // {
  30. // break;
  31. // }
  32. // Now get the computer's number;
  33. Random rnd = new Random();
  34. int computer_guess = rnd.Next(1, 100);
  35. Console.WriteLine("Here is my number, {0}: {1}", name, computer_guess);
  36.  
  37. if (computer_guess < 50 && players_number == 1)
  38. {
  39. Console.WriteLine("Player WINS!!!");
  40. give_Advice(name, age);
  41.  
  42. }
  43. else if (computer_guess >= 50 && players_number == 100)
  44. {
  45. Console.WriteLine("Player WINS!!!");
  46. give_Advice(name, age);
  47.  
  48. }
  49. else
  50. {
  51. Console.WriteLine("Player loses!!!");
  52. }
  53. Console.WriteLine("Play again, {0} ?", name);
  54. playAgainCode = int.Parse(Console.ReadLine());
  55. Console.ReadLine();
  56. }
  57. }
  58.  
  59. static void give_Advice(string name, int age)
  60. {
  61. 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());
  62. }
  63.  
  64. }
  65. }
Add Comment
Please, Sign In to add comment