Advertisement
sylviapsh

Party songs

Dec 27th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2. class Party
  3. {
  4.   static void Main()
  5.   {
  6.     //Telerik Academy
  7.     //Within 24 hour time span you have a start and end time of a party. A music band sings 5-minute songs and wants to know the maximum amount of songs they would sing. If there is no time for a last song they won't start singing it. The format for the start and end times is: 16 01 and on the next row 17 30
  8.  
  9.     string inputStartTime = Console.ReadLine(),
  10.            inputEndTime = Console.ReadLine();
  11.  
  12.     string[] inputStartTimeSplitted = inputStartTime.Split(' ');
  13.     int[] startTime = Array.ConvertAll<string, int>(inputStartTimeSplitted, int.Parse);
  14.  
  15.     string[] inputEndTimeSplitted = inputEndTime.Split(' ');
  16.     int[] endTime = Array.ConvertAll<string, int>(inputEndTimeSplitted, int.Parse);
  17.  
  18.     int startMinutes = startTime[0] * 60 + startTime[1];
  19.     int endMinutes = endTime[0] * 60 + endTime[1];
  20.     int timeSpan = endMinutes - startMinutes;
  21.     int numberOfSongs = timeSpan / 5;
  22.  
  23.     Console.WriteLine(numberOfSongs);
  24.   }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement