Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4.  
  5. namespace lottery
  6. {
  7. class Program
  8. {
  9. static Task Main(string[] args)
  10. => Start(args);
  11.  
  12. static async Task Start(string[] args)
  13. {
  14. bool playing = true;
  15.  
  16. while (playing)
  17. {
  18. Random r = new Random();
  19.  
  20. int[] random_numbers = new int[6] { r.Next(0, 70), r.Next(0, 70), r.Next(0, 70), r.Next(0, 70), r.Next(0, 70), r.Next(0, 25) };
  21. int[] numbers = new int[6];
  22. List<int> winning_numbers = new List<int>();
  23.  
  24. Console.WriteLine("Do you want to use quick pick, yes or no");
  25.  
  26. String answer = Console.ReadLine();
  27.  
  28. if (answer.ToLower() == "yes" || answer.ToLower() == "y")
  29. {
  30. for (int y = 0; y < 5; y++)
  31. {
  32. numbers[y] = r.Next(0, 70);
  33. }
  34.  
  35. numbers[5] = r.Next(0, 25);
  36. }
  37. else
  38. {
  39. for (int x = 0; x < 6; x++)
  40. {
  41. // Debuging: Tells you winning number
  42. Console.WriteLine(random_numbers[x]);
  43. Console.WriteLine($"Please input your {x + 1} number");
  44.  
  45. numbers[x] = Convert.ToInt32(Console.ReadLine());
  46. }
  47. }
  48.  
  49. String total = "0";
  50. int matches = 0;
  51.  
  52. for (int i = 0; i < 5; i++)
  53. {
  54. if (random_numbers[i] == numbers[i])
  55. {
  56. if (matches == 0)
  57. {
  58. total = "10";
  59. }
  60. else
  61. {
  62. total += "0";
  63. }
  64.  
  65. winning_numbers.Add(random_numbers[i]);
  66. matches++;
  67. }
  68. }
  69.  
  70. if (random_numbers[5] == numbers[5])
  71. {
  72. if (matches == 0)
  73. {
  74. total = "1";
  75. }
  76.  
  77. total = total.Replace('1', '5');
  78. total += "0";
  79.  
  80. winning_numbers.Add(random_numbers[5]);
  81. matches++;
  82. }
  83.  
  84. if (matches == 0)
  85. {
  86. Console.WriteLine("YOU LOSER");
  87. }
  88. else
  89. {
  90. foreach (int num in numbers)
  91. {
  92. Console.Write(num + " ");
  93. }
  94.  
  95. Console.WriteLine();
  96.  
  97. foreach (int num in winning_numbers)
  98. {
  99. Console.Write(num + " ");
  100. }
  101.  
  102. Console.WriteLine();
  103.  
  104. Console.WriteLine($"You've made {matches} matches and won ${total}");
  105. }
  106.  
  107. Console.WriteLine("Would you like to play again, yes or no");
  108. String replay = Console.ReadLine();
  109.  
  110. if (replay.ToLower() == "no" || replay.ToLower() == "n")
  111. {
  112. playing = false;
  113. }
  114. }
  115. }
  116. }
  117. }
  118.  
  119. // 1 = 10; 2 = 100; 3 = 1000; 4 = 10000; 5 = 100000; 6 = 1000000;
  120. // special changes first 1 to 5;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement