Advertisement
JuliaPetkova

Untitled

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