Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SoftUniCamp
- {
- class Program
- {
- static void Main(string[] args)
- {
- int numberOfInputs = int.Parse(Console.ReadLine());
- int totalCountOfPeople = 0;
- double byCar = 0;
- double byBus = 0;
- double bySmallBus = 0;
- double byBigBus = 0;
- double byTrain = 0;
- for (int currInput = 0; currInput < numberOfInputs; currInput++)
- {
- int sizeOfGroup = int.Parse(Console.ReadLine());
- totalCountOfPeople += sizeOfGroup;
- if (sizeOfGroup <= 5)
- {
- byCar += sizeOfGroup;
- }
- else if (sizeOfGroup >= 6 && sizeOfGroup <= 12)
- {
- byBus += sizeOfGroup;
- }
- else if (sizeOfGroup >= 13 && sizeOfGroup <= 25)
- {
- bySmallBus += sizeOfGroup;
- }
- else if (sizeOfGroup >= 26 && sizeOfGroup <= 40)
- {
- byBigBus += sizeOfGroup;
- }
- else
- {
- byTrain += sizeOfGroup;
- }
- }
- double percentByCar = (byCar / totalCountOfPeople) * 100;
- double percentByBus = (byBus / totalCountOfPeople) * 100;
- double percentBySmallBus = (bySmallBus / totalCountOfPeople) * 100;
- double percentByBigBus = (byBigBus / totalCountOfPeople) * 100;
- double percentByTrain = (byTrain / totalCountOfPeople) * 100;
- Console.WriteLine($"{percentByCar:f2}%");
- Console.WriteLine($"{percentByBus:f2}%");
- Console.WriteLine($"{percentBySmallBus:f2}%");
- Console.WriteLine($"{percentByBigBus:f2}%");
- Console.WriteLine($"{percentByTrain:f2}%");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement