Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _03.Logistics
- {
- class Program
- {
- static void Main(string[] args)
- {
- int count = int.Parse(Console.ReadLine());
- double price = 0;
- double p1 = 0;
- double p2 = 0;
- double p3 = 0;
- double p1Percent = 0;
- double p2Percent = 0;
- double p3Percent = 0;
- double totalWeight = 0;
- for (int i = 0; i < count; i++)
- {
- int weight = int.Parse(Console.ReadLine());
- if (weight <= 3)
- {
- price += weight*200;
- p1 += weight;
- }
- else if (weight<=11)
- {
- price +=weight*175;
- p2 += weight;
- }
- else if (weight >= 12)
- {
- price +=weight*120;
- p3 += weight;
- }
- totalWeight = p1 + p2 + p3;
- p1Percent = p1 / totalWeight * 100;
- p2Percent = p2 / totalWeight * 100;
- p3Percent = p3 / totalWeight * 100;
- }
- double average = price / totalWeight;
- Console.WriteLine($"{average:f2}");
- Console.WriteLine($"{p1Percent:f2}%");
- Console.WriteLine($"{p2Percent:f2}%");
- Console.WriteLine($"{p3Percent:f2}%");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment