Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 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 Logistic
  8. {
  9. class Logistic
  10. {
  11. static void Main(string[] args)
  12. {
  13. decimal goodsAmount = decimal.Parse(Console.ReadLine());
  14. decimal bus = 0;
  15. decimal truck = 0;
  16. decimal train = 0;
  17.  
  18. for (decimal i = 0; i < goodsAmount; i++)
  19. {
  20. decimal weight = decimal.Parse(Console.ReadLine());
  21.  
  22. if (weight >= 11)
  23. {
  24. train += weight;
  25. }
  26. else if (weight > 3)
  27. {
  28. truck += weight;
  29. }
  30. else
  31. {
  32. bus += weight;
  33. }
  34. }
  35. decimal sumWeight = (truck + train + bus);
  36. decimal busPercent = bus / sumWeight * 100;
  37. decimal truckPercent = truck / sumWeight * 100;
  38. decimal trainPercent = train / sumWeight * 100;
  39. decimal averragePrice = (bus * 200 + truck * 175 + train * 120) / sumWeight;
  40.  
  41. Console.WriteLine($"{averragePrice:f2}");
  42. Console.WriteLine($"{busPercent:f2}%");
  43. Console.WriteLine($"{truckPercent:f2}%");
  44. Console.WriteLine($"{trainPercent:f2}%");
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement