Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class LoadTimeCalculator
- {
- static void Main()
- {
- Console.WriteLine("This program reads a report of web sites and load times. After that it calculates the average load time for each URL.");
- Console.WriteLine("Please enter a report:");
- Dictionary<string, List<double>> dict = new Dictionary<string, List<double>>();
- string input = Console.ReadLine();
- while (input != string.Empty)
- {
- input = input.Substring(18);
- string [] splitted = input.Split(' ');
- if (!dict.Keys.Contains(splitted[0]))
- {
- dict.Add(splitted[0], new List<double> { double.Parse(splitted[1]) });
- }
- else
- {
- dict[splitted[0]].Add(double.Parse(splitted[1]));
- }
- input = Console.ReadLine();
- }
- Console.WriteLine("The average load time for each URL is:");
- foreach (var entry in dict)
- {
- Console.WriteLine("{0} -> {1}", entry.Key, entry.Value.Average());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement