skipter

C# BPM Counter / minutes - seconds

Jun 8th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2. namespace p._5_BPM_Counter
  3. {
  4.     class Program
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             double beatsPerMinute = double.Parse(Console.ReadLine());
  9.             double numberOfBeatsInSeconds = double.Parse(Console.ReadLine());
  10.  
  11.             double bars = Math.Round(numberOfBeatsInSeconds * 0.25, 1);
  12.             double totalSeconds = ((int)numberOfBeatsInSeconds * 60 / (int)beatsPerMinute);
  13.             int minutes = (int) totalSeconds / 60;
  14.             double seconds = totalSeconds % 60;
  15.  
  16.             Console.WriteLine("{0} bars - {1}m {2}s", Math.Round(bars, 1), minutes, Math.Floor(seconds));
  17.  
  18.         }
  19.     }
  20. }
Add Comment
Please, Sign In to add comment