Advertisement
_CodeBehind

5.* Note Statistics

Feb 19th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _5.Note_Statistics
  6. {
  7.     public class MusicMakesUsFree
  8.     {
  9.         public static void Main()
  10.         {
  11.             var chordBook = Console.ReadLine().Split(' ').ToList();
  12.  
  13.             double naturalSum = 0;
  14.             double sharpsSum = 0;
  15.             List<string> notes = new List<string>();
  16.             List<string> naturals = new List<string>();
  17.             List<string> sharps = new List<string>();
  18.  
  19.             foreach (var chord in chordBook)
  20.             {
  21.                 switch (chord)
  22.                 {
  23.                     case "261.63":
  24.                         naturalSum += 261.63;
  25.                         naturals.Add("C");
  26.                         notes.Add("C");
  27.                         break;
  28.                     case "277.18":
  29.                         sharpsSum += 277.18;
  30.                         sharps.Add("C#");
  31.                         notes.Add("C#");
  32.                         break;
  33.                     case "293.66":
  34.                         naturalSum += 293.66;
  35.                         naturals.Add("D");
  36.                         notes.Add("D");
  37.                         break;
  38.                     case "311.13":
  39.                         sharpsSum += 311.13;
  40.                         sharps.Add("D#");
  41.                         notes.Add("D#");
  42.                         break;
  43.                     case "329.63":
  44.                         naturalSum += 329.63;
  45.                         naturals.Add("E");
  46.                         notes.Add("E");
  47.                         break;
  48.                     case "349.23":
  49.                         naturalSum += 349.23;
  50.                         naturals.Add("F");
  51.                         notes.Add("F");
  52.                         break;
  53.                     case "369.99":
  54.                         sharpsSum += 369.99;
  55.                         sharps.Add("F#");
  56.                         notes.Add("F#");
  57.                         break;
  58.                     case "392.0":
  59.                         naturalSum += 392.00;
  60.                         naturals.Add("G");
  61.                         notes.Add("G");
  62.                         break;
  63.                     case "415.3":
  64.                         sharpsSum += 415.30;
  65.                         sharps.Add("G#");
  66.                         notes.Add("G#");
  67.                         break;
  68.                     case "440.0":
  69.                         naturalSum += 440.00;
  70.                         naturals.Add("A");
  71.                         notes.Add("A");
  72.                         break;
  73.                     case "466.16":
  74.                         sharpsSum += 466.16;
  75.                         sharps.Add("A#");
  76.                         notes.Add("A#");
  77.                         break;
  78.                     case "493.88":
  79.                         naturalSum += 493.88;
  80.                         naturals.Add("B");
  81.                         notes.Add("B");
  82.                         break;
  83.                     default:
  84.                         break;
  85.                 }
  86.  
  87.             }
  88.             Console.WriteLine($"Notes: {string.Join(" ",notes)}");
  89.             Console.WriteLine($"Naturals: {string.Join(", ", naturals)}");
  90.             Console.WriteLine($"Sharps: {string.Join(", ", sharps)}");
  91.             Console.WriteLine($"Naturals sum: {naturalSum}");
  92.             Console.WriteLine($"Sharps sum: {sharpsSum}");
  93.         }
  94.     }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement