View difference between Paste ID: eYK7sPft and Aaq9G9gQ
SHOW: | | - or go back to the newest paste.
1
using System;
2
using System.Globalization;
3
class Program
4
{
5
    static void Main()
6
    {
7
        int inputCount = 0;
8
        int averageSeconds = 0;
9
        int totalSeconds = 0;
10
        //DateTime data;
11
        string[] stars =
12
        {
13
            "Gold Star", // star was lowercase
14
            "Silver Star",
15
            "Bronze Star"
16
        };
17
        string input = Console.ReadLine(); // read input
18
        do
19
        {
20-
            int minutes = int.Parse(input.Substring(0, 2));
20+
            int minutes = int.Parse(input.Substring(0, 2)); // first two digits will always be minutes since input is never larger than 99:59
21-
            int seconds = int.Parse(input.Substring(3, 2));
21+
            int seconds = int.Parse(input.Substring(3, 2)); // digits after colon are seconds 
22
            //data = DateTime.ParseExact(input, "mm:ss", CultureInfo.InvariantCulture);
23
            // datetime not suitable since anything above 59:59 isnt valid
24
            inputCount++;
25
            totalSeconds += minutes * 60 + seconds; // add time
26
            input = Console.ReadLine();
27
        } while (input != "Quit");
28
29
        averageSeconds = (int)Math.Ceiling((double)totalSeconds / inputCount); // get average time and round up
30
        if (averageSeconds < 720)
31
        {
32
            Console.WriteLine(stars[0]);
33
        }
34
        else if (averageSeconds >= 720 && averageSeconds < 1440)
35
        {
36
            Console.WriteLine(stars[1]);
37
        }
38
        else
39
        {
40
            Console.WriteLine(stars[2]);
41
        }
42
        Console.WriteLine("Games - {0} \\ Average seconds - {1}", inputCount, averageSeconds); // escaped '\'
43
        return;
44
45
    }
46
}