Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace homeworkforloop
- {
- class Program
- {
- static void Main(string[] args)
- {
- int logisticCount = int.Parse(Console.ReadLine());
- double busPrice = 0.0;
- double truckPrice = 0.0;
- double trainPrice = 0.0;
- var averagePrice = 0.0;
- var busWeight = 0.0;
- var truckWeight = 0.0;
- var trainWeight = 0.0;
- for (int i = 1; i <= logisticCount; i++)
- {
- int logisticWeight = int.Parse(Console.ReadLine());
- if (logisticWeight <= 3)
- {
- busWeight += logisticWeight;
- busPrice = busWeight * 200.0;
- }
- else if (logisticWeight <= 11)
- {
- truckWeight += logisticWeight;
- truckPrice = truckWeight * 175.0;
- }
- else
- {
- trainWeight += logisticWeight;
- trainPrice = trainWeight * 120.0;
- }
- }
- var totalWeight = busWeight + truckWeight + trainWeight;
- averagePrice = (busPrice + truckPrice + trainPrice) / totalWeight;
- var busPercent = (busWeight / totalWeight) * 100.0;
- var truckPercent = (truckWeight / totalWeight) * 100.0;
- var trainPercent = (trainWeight / totalWeight) * 100.0;
- Console.WriteLine($"{averagePrice:f2}");
- Console.WriteLine($"{busPercent:f2}%");
- Console.WriteLine($"{truckPercent:f2}%");
- Console.WriteLine($"{trainPercent:f2}%");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement