Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace frequencies
- {
- class Program
- {
- static void Main(string[] args)
- {
- double[] inputPower = Console.ReadLine().Split(new char[] { ' ', '.' }).Select(double.Parse).ToArray();
- double[] usagePerHour = Console.ReadLine().Split(new char[] { ' ', '.' }).Select(double.Parse).ToArray();
- int hours = int.Parse(Console.ReadLine());
- List<double> usage = new List<double>();
- for(int i=0; i<usagePerHour.Length; i++)
- {
- double result = usagePerHour[i] * hours;
- usage.Add(result);
- }
- for(int i=0; i<inputPower.Length; i++)
- {
- if(inputPower[i] > usage[i])
- {
- double left = inputPower[i] - usage[i];
- double percent = left * 100.0 / inputPower[i];
- Console.WriteLine($"Battery {i + 1}: {left:F2} mAh ({percent:F2}%)");
- }
- else
- {
- double hoursDead = Math.Ceiling(inputPower[i] / usagePerHour[i]);
- Console.WriteLine($"Battery {i + 1}: dead (lasted {hoursDead} hours)");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement