JuliaPetkova

Untitled

Jun 24th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 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 _3_05.Note_Statistics
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. List<string> frequencies = Console.ReadLine().Split(' ').ToList();
  14.  
  15. List<string> notes = new List<string>();
  16.  
  17. List<string> naturals = new List<string>();
  18. List<string> sharps = new List<string>();
  19.  
  20. double natSum = 0;
  21. double sharpSum = 0;
  22.  
  23.  
  24. foreach (var item in frequencies)
  25. {
  26. switch (item)
  27. {
  28. case "261.63":
  29. notes.Add("C");
  30. natSum += double.Parse(item);
  31. break;
  32. case "277.18":
  33. notes.Add("C#");
  34. sharpSum += double.Parse(item);
  35. break;
  36.  
  37. case "293.66":
  38. notes.Add("D");
  39. natSum += double.Parse(item);
  40. break;
  41.  
  42. case "311.13":
  43. notes.Add("D#");
  44. sharpSum += double.Parse(item);
  45. break;
  46. case "329.63":
  47. notes.Add("E");
  48. natSum += double.Parse(item);
  49. break;
  50. case "349.23":
  51. notes.Add("F");
  52. natSum += double.Parse(item);
  53. break;
  54. case "369.99":
  55. notes.Add("F#");
  56. sharpSum += double.Parse(item);
  57. break;
  58. case "392.0":
  59. notes.Add("G");
  60. natSum += double.Parse(item);
  61. break;
  62. case "415.30":
  63. notes.Add("G#");
  64. sharpSum += double.Parse(item);
  65. break;
  66. case "440.0":
  67. notes.Add("A");
  68. natSum += double.Parse(item);
  69. break;
  70. case "466.16":
  71. notes.Add("A#");
  72. sharpSum += double.Parse(item);
  73. break;
  74. case "493.88":
  75. notes.Add("B");
  76. natSum += double.Parse(item);
  77. break;
  78.  
  79. default:
  80. break;
  81. }
  82. }
  83. Console.WriteLine("Notes: " + string.Join(" ", notes));
  84.  
  85. foreach (var item in notes)
  86. {
  87. if (!item.Contains("#"))
  88. {
  89. naturals.Add(item);
  90. }
  91. else
  92. {
  93. sharps.Add(item);
  94. }
  95. }
  96. Console.WriteLine("Naturals: " + string.Join(", ", naturals));
  97. Console.WriteLine("Sharps: " + string.Join(", ", sharps));
  98. Console.WriteLine("Naturals sum: {0:0.##}", natSum);
  99. Console.WriteLine("Sharps sum: {0:0.##}", sharpSum);
  100.  
  101. }
  102. }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment