Guest User

Untitled

a guest
Jun 19th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 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. namespace HelloWorld
  5. {
  6. public class Hello
  7. {
  8. static void Main()
  9. {
  10. Console.WriteLine("Welcome to the Online Gaming Forum!");
  11. string name;
  12. int age;
  13. Console.Write("Enter your name: ");
  14. name = Console.ReadLine();
  15. Console.WriteLine("How old are you, {0}?", name);
  16. age = int.Parse(Console.ReadLine());
  17. Console.WriteLine("Let's play a game, {0}", name);
  18. Console.WriteLine("I will guess a number between 1 and 100");
  19. Console.WriteLine("All you need to do, {0}, is say whether my number is closer to 1 or 100", name);
  20. Console.WriteLine("If you win, {0}, you will get a fabulous prize!", name);
  21. int playAgainCode = 0;
  22.  
  23. for (int i = 0; i < 5; i++)
  24. while(playAgainCode!= -1)
  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. else if (computer_guess >= 50 && players_number == 100)
  43. {
  44. Console.WriteLine("Player WINS!!!");
  45.  
  46. }
  47. else
  48. {
  49. Console.WriteLine("Player loses!!!");
  50. }give_Advice( name, age)
  51. Console.WriteLine("Play again, {0} ?", name);
  52. playAgainCode = int.Parse(Console.ReadLine());
  53. Console.ReadLine();
  54. }
  55. }
  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