Advertisement
nevenailievaa

05.GameOfIntervals

Oct 30th, 2023
742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. int plays=int.Parse(Console.ReadLine());
  2. double point = 0;
  3. double toTenPercentsAmount = 0;
  4. double toTwentyPercents = 0;
  5. double totwetyNine = 0;
  6. double toThirtyNicePecn = 0;
  7. double tofifty = 0;
  8. double toHundered = 0;
  9. double invalidNum = 0;
  10.  
  11. for (int i = 0; i < plays; i++)
  12. {
  13.     int pointsScored=int.Parse((Console.ReadLine()));
  14.     if (pointsScored >= 0 && pointsScored <= 9)
  15.     {
  16.         point += pointsScored * 0.2;
  17.         toTenPercentsAmount++;
  18.     }
  19.     else if (pointsScored >= 10 && pointsScored <= 19)
  20.     {
  21.         point += pointsScored * 0.3;
  22.         toTwentyPercents++;
  23.     }
  24.     else if (pointsScored >= 20 && pointsScored <= 29)
  25.     {
  26.         point += pointsScored * 0.4;
  27.         totwetyNine++;
  28.     }
  29.     else if (pointsScored >= 30 && pointsScored <= 39)
  30.     {
  31.         point += 50;
  32.         toThirtyNicePecn++;
  33.     }
  34.     else if (pointsScored >= 40 && pointsScored <= 50)
  35.     {
  36.         point += 100;
  37.         toHundered++;
  38.     }
  39.     else
  40.     {
  41.         invalidNum++;
  42.         point /= 2;
  43.  
  44.     }
  45.  
  46. }
  47.  
  48. double toTenPercents = (double)toTenPercentsAmount / plays * 100;
  49. double tonineteen=(double)toTwentyPercents / plays * 100;
  50. double twentyNine=(double)totwetyNine / plays * 100;
  51. double thirtynine=(double)toThirtyNicePecn / plays * 100;
  52. double toHundredPercents = (double)toHundered / plays * 100;
  53. double invalidPercents = (double)invalidNum / plays * 100;
  54. Console.WriteLine($"{point:f2}");
  55. Console.WriteLine($"From 0 to 9: {toTenPercents:F2}%");
  56. Console.WriteLine($"From 10 to 19: {tonineteen:f2}%");
  57. Console.WriteLine($"From 20 to 29: {twentyNine:f2}%");
  58. Console.WriteLine($"From 30 to 39: {thirtynine:f2}%");
  59. Console.WriteLine($"From 40 to 50: {toHundredPercents:f2}%");
  60. Console.WriteLine($"Invalid numbers: {invalidPercents:F2}%");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement