Guest User

Untitled

a guest
Jun 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 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.  
  27. Console.WriteLine("OK, {0}, Let's Go! Enter you GUESS. Enter either the number 1 or 100, {0}", name);
  28. int players_number = int.Parse(Console.ReadLine());
  29. // if (players_number == -1)
  30. // {
  31. // break;
  32. // }
  33. // Now get the computer's number;
  34. Random rnd = new Random();
  35. int computer_guess = rnd.Next(1, 100);
  36. Console.WriteLine("Here is my number, {0}: {1}", name, computer_guess);
  37.  
  38. if (computer_guess < 50 && players_number == 1)
  39. {
  40. Console.WriteLine("Player WINS!!!");
  41. give_Advice(name, age);
  42.  
  43. }
  44. else if (computer_guess >= 50 && players_number == 100)
  45. {
  46. Console.WriteLine("Player WINS!!!");
  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