koksibg

SoftUniKamp

Nov 20th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.82 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 SoftUniKamp
  8. {
  9.     class SoftUniKamp
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int groop = int.Parse(Console.ReadLine());
  14.             double sumPeopleCar = 0;
  15.             double sumPeopleBus = 0;
  16.             double sumPeopleMiniBus = 0;
  17.             double sumPeopleBigBus = 0;
  18.             double sumPeopleTrain = 0;
  19.             double sumCar = 0;
  20.             double sumBus = 0;
  21.             double sumMiniBus = 0;
  22.             double sumBigBus = 0;
  23.             double sumTrain = 0;
  24.             double sumPeople = 0;
  25.             for (int i = 0;  i < groop; i++)
  26.             {
  27.                 int people = int.Parse(Console.ReadLine());
  28.                 sumPeople += people;
  29.                 if (people <= 5)                  sumPeopleCar += people;
  30.                 if (people > 5 && people <= 12)   sumPeopleBus += people;
  31.                 if (people > 12 && people <= 25)  sumPeopleMiniBus += people;
  32.                 if (people > 25 && people <= 40)  sumPeopleBigBus += people;
  33.                 if (people > 40)                  sumPeopleTrain += people;
  34.             }
  35.             sumCar = (sumPeopleCar / sumPeople) * 100; // car
  36.             sumBus = sumPeopleBus / sumPeople * 100;   // bus
  37.             sumMiniBus = sumPeopleMiniBus / sumPeople * 100; // minibus
  38.             sumBigBus = sumPeopleBigBus / sumPeople * 100;  // bigbus
  39.             sumTrain = sumPeopleTrain / sumPeople * 100;  // train
  40.             Console.WriteLine("{0:f2}", sumCar);
  41.             Console.WriteLine("{0:f2}", sumBus);
  42.             Console.WriteLine("{0:f2}", sumMiniBus);
  43.             Console.WriteLine("{0:f2}", sumBigBus);
  44.             Console.WriteLine("{0:f2}", sumTrain);
  45.         }
  46.     }
  47. }
Add Comment
Please, Sign In to add comment