Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LearnToProgramCSharp
- {
- class Program
- {
- static void Main(string[] args)
- {
- double[] capacity = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
- double[] usageForHour = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
- int amountHours = int.Parse(Console.ReadLine());
- double longevity = 0.00;
- for (int i = 0; i < capacity.Length; i++)
- {
- if ((capacity[i] / usageForHour[i]) < amountHours)
- {
- Console.WriteLine("Battery {0}: dead (lasted {1} hours)", i + 1, Math.Ceiling(capacity[i] / usageForHour[i]));
- }
- else if ((capacity[i] / usageForHour[i]) > amountHours)
- {
- longevity = capacity[i] - (usageForHour[i] * amountHours);
- Console.WriteLine("Battery {0}: {1:F2} mAh ({2:F2})%", i + 1, longevity, (longevity * 100 / capacity[i]));
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement