Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Globalization;
- class Program
- {
- static void Main()
- {
- int inputCount = 0;
- int averageSeconds = 0;
- int totalSeconds = 0;
- //DateTime data;
- string[] stars =
- {
- "Gold Star", // star was lowercase
- "Silver Star",
- "Bronze Star"
- };
- string input = Console.ReadLine(); // read input
- do
- {
- int minutes = int.Parse(input.Substring(0, 2)); // first two digits will always be minutes since input is never larger than 99:59
- int seconds = int.Parse(input.Substring(3, 2)); // digits after colon are seconds
- //data = DateTime.ParseExact(input, "mm:ss", CultureInfo.InvariantCulture);
- // datetime not suitable since anything above 59:59 isnt valid
- inputCount++;
- totalSeconds += minutes * 60 + seconds; // add time
- input = Console.ReadLine();
- } while (input != "Quit");
- averageSeconds = (int)Math.Ceiling((double)totalSeconds / inputCount); // get average time and round up
- if (averageSeconds < 720)
- {
- Console.WriteLine(stars[0]);
- }
- else if (averageSeconds >= 720 && averageSeconds < 1440)
- {
- Console.WriteLine(stars[1]);
- }
- else
- {
- Console.WriteLine(stars[2]);
- }
- Console.WriteLine("Games - {0} \\ Average seconds - {1}", inputCount, averageSeconds); // escaped '\'
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment