Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Switch_Statements
  8. {
  9. class Program
  10. {
  11. static string highScorePlayer = "Steve";
  12. static int highScore = 999;
  13. static void Main(string[] args)
  14. {
  15.  
  16.  
  17. NewScore();
  18.  
  19.  
  20.  
  21. }
  22. static void NewScore()
  23. {
  24. Console.WriteLine("Enter your score: ");
  25. string playerScore = Console.ReadLine();
  26. if(int.TryParse(playerScore,out int Score))
  27. {
  28. if (Score > highScore)
  29. {
  30. Console.WriteLine("Enter your name: ");
  31. string playerName = Console.ReadLine();
  32. Console.WriteLine("New highscore is " +
  33. "" + Score);
  34. Console.WriteLine("New highscore holder is " + playerName);
  35. }
  36. else
  37. {
  38. Console.WriteLine("The old highscore of " + highScore + " could not be broken and is still held by " +highScorePlayer);
  39. }
  40. }
  41. else
  42. {
  43. Console.WriteLine("Enter a numeric value.");
  44. }
  45. Console.ReadKey();
  46. }
  47.  
  48. }
  49. }
  50. /*/
  51. int age = 25;
  52.  
  53. switch (age)
  54. {
  55. case 15:
  56. Console.WriteLine("too young to enter!");
  57. break;
  58. case 25:
  59. Console.WriteLine("enter for free!!!");
  60. break;
  61. case 40:
  62. Console.WriteLine("too old");
  63. break;
  64. default:
  65. Console.WriteLine("how old are u then?");
  66. break;
  67. }
  68. /*/
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76. /*/
  77. Console.WriteLine("Enter your age:");
  78. string age = Console.ReadLine();
  79.  
  80. if (int.TryParse(age, out int ageInt))
  81. {
  82.  
  83. if (ageInt == 25)
  84. {
  85. Console.WriteLine("You can enter for free");
  86. }
  87. else if (ageInt<20 || ageInt>29)
  88. {
  89. Console.WriteLine("You can't enter this place");
  90.  
  91. }
  92. else
  93. {
  94. Console.WriteLine("How old are you?");
  95. }
  96.  
  97. }
  98. else
  99. {
  100. Console.WriteLine("Enter number value.");
  101. }
  102. /*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement