Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace SoftUniCamp
- {
- using System;
- class SoftUniCamp
- {
- static void Main()
- {
- int numberOfInputs = int.Parse(Console.ReadLine());
- int peopleTravellingByCar = 0;
- int peopleTravellingByVerySmallBus = 0;
- int peopleTravellingBySmallBus = 0;
- int peopleTraveliingByBus = 0;
- int peopleTravellingByTrain = 0;
- double totalTravellers = 0;
- for (int currInput = 0; currInput < numberOfInputs; currInput++)
- {
- int groupSize = int.Parse(Console.ReadLine());
- totalTravellers += groupSize;
- if (groupSize <= 5)
- {
- peopleTravellingByCar += groupSize;
- }
- else if (groupSize >= 6 && groupSize <= 12)
- {
- peopleTravellingByVerySmallBus += groupSize;
- }
- else if (groupSize >= 13 && groupSize <= 25)
- {
- peopleTravellingBySmallBus += groupSize;
- }
- else if (groupSize >= 26 && groupSize <= 40)
- {
- peopleTraveliingByBus += groupSize;
- }
- else if (groupSize >= 41)
- {
- peopleTravellingByTrain += groupSize;
- }
- }
- Console.WriteLine($"{((peopleTravellingByCar / totalTravellers) * 100.0):f2}%");
- Console.WriteLine($"{((peopleTravellingByVerySmallBus / totalTravellers) * 100.0):f2}%");
- Console.WriteLine($"{((peopleTravellingBySmallBus / totalTravellers) * 100.0):f2}%");
- Console.WriteLine($"{((peopleTraveliingByBus / totalTravellers) * 100.0):f2}%");
- Console.WriteLine($"{((peopleTravellingByTrain / totalTravellers) * 100.0):f2}%");
- }
- }
- }
Add Comment
Please, Sign In to add comment