Advertisement
DidiMilikina

SoftUni Camp

Apr 4th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _04.SoftUni_Camp
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var numberOfGroups = int.Parse(Console.ReadLine());
  14.             var allPeople = 0;
  15.             var peopleGroupInCar = 0;
  16.             var peopleInGroupInMicrobus = 0;
  17.             var peopleInGroupInLittleBus = 0;
  18.             var peopleInGroupInBigBus = 0;
  19.             var peopleInGroupInTrain = 0;
  20.  
  21.             for (int i = 0; i < numberOfGroups; i++)
  22.             {
  23.                 var people = int.Parse(Console.ReadLine());
  24.  
  25.                 if (people <= 5)
  26.                 {
  27.                     peopleGroupInCar++;
  28.                 }
  29.                 else if (people >= 6 && people <= 12)
  30.                 {
  31.                     peopleInGroupInMicrobus++;
  32.                 }
  33.                 else if (people >= 13 && people <= 25)
  34.                 {
  35.                     peopleInGroupInLittleBus++;
  36.                 }
  37.                 else if (people >= 26 && people <= 40)
  38.                 {
  39.                     peopleInGroupInBigBus++;
  40.                 }
  41.                 else
  42.                 {
  43.                     peopleInGroupInTrain++;
  44.                 }
  45.             }
  46.  
  47.             var p1 = peopleGroupInCar / allPeople * 100;
  48.             var p2 = peopleInGroupInMicrobus / allPeople * 100;
  49.             var p3 = peopleInGroupInLittleBus / allPeople * 100;
  50.             var p4 = peopleInGroupInBigBus / allPeople * 100;
  51.             var p5 = peopleInGroupInTrain / allPeople * 100;
  52.             Console.WriteLine($"{p1:f2}%");
  53.             Console.WriteLine($"{p2:f2}%");
  54.             Console.WriteLine($"{p3:f2}%");
  55.             Console.WriteLine($"{p4:f2}%");
  56.             Console.WriteLine($"{p5:f2}%");
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement