Advertisement
aggressiveviking

Untitled

Feb 6th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03.Logistics
  4. {
  5. class Logistics
  6. {
  7. static void Main(string[] args)
  8. {
  9. int n = int.Parse(Console.ReadLine());
  10.  
  11. double minibus = 0;
  12. double truck = 0;
  13. double train = 0;
  14. double sumLoad = 0;
  15.  
  16. for (int i = 1; i <= n; i++)
  17. {
  18. double ton = double.Parse(Console.ReadLine());
  19.  
  20. if (ton <= 3)
  21. {
  22. minibus += ton;
  23. }
  24. if (ton <= 11 && ton >= 4)
  25. {
  26. truck += ton;
  27. }
  28. if (ton >= 12)
  29. {
  30. train += ton;
  31. }
  32. sumLoad += ton;
  33. }
  34.  
  35. double sumAllLoads = minibus + truck + train;
  36.  
  37. double avgMinibus = minibus * 200;
  38. double avgTruck = truck * 175;
  39. double avgTrain = train * 120;
  40.  
  41. double average = (avgMinibus + avgTruck + avgTrain) / sumAllLoads;
  42.  
  43. Console.WriteLine($"{average:f2}");
  44. Console.WriteLine($"{(minibus / sumAllLoads * 100):f2}" + "%");
  45. Console.WriteLine($"{(truck / sumAllLoads * 100):f2}" + "%");
  46. Console.WriteLine($"{(train / sumAllLoads * 100):f2}" + "%");
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement