desislava_topuzakova

04.

Dec 5th, 2021
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int count = int.Parse(Console.ReadLine());
  10. int countLight = 0;
  11. int countModerate = 0;
  12. int countStrong = 0;
  13. int countVeryStrong = 0;
  14.  
  15.  
  16. for (int earthquake = 1; earthquake <= count; earthquake++)
  17. {
  18. double rihterScale = double.Parse(Console.ReadLine());
  19. if (rihterScale >= 0 && rihterScale <= 4)
  20. {
  21. countLight++;
  22. }
  23. else if (rihterScale > 4 && rihterScale <= 6)
  24. {
  25. countModerate++;
  26. }
  27. else if (rihterScale > 6 && rihterScale <= 7)
  28. {
  29. countStrong++;
  30. }
  31. else if (rihterScale > 7)
  32. {
  33. countVeryStrong++;
  34. }
  35.  
  36. }
  37. double percentLight = countLight * 1.0 / count * 100;
  38. double percentModerate = countModerate * 1.0 / count * 100;
  39. double percentStrong = countStrong * 1.0 / count * 100;
  40. double percentVeryStrong = countVeryStrong * 1.0 / count * 100;
  41.  
  42. Console.WriteLine($"Light: {percentLight:F2}%");
  43. Console.WriteLine($"Moderate: {percentModerate:F2}%");
  44. Console.WriteLine($"Strong: {percentStrong:F2}%");
  45. Console.WriteLine($"Very Strong: {percentVeryStrong:F2}%");
  46. }
  47. }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment