fbinnzhivko

01.01 Electricity

Apr 16th, 2016
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1. using System;
  2.  
  3. class Electricity
  4. {
  5.     static void Main()
  6.     {
  7.         int floors = int.Parse(Console.ReadLine());
  8.         int flats = int.Parse(Console.ReadLine());
  9.         DateTime time = DateTime.Parse(Console.ReadLine());
  10.         double flatsInDorms = floors * flats;
  11.         double lampConsumption = 100.53;
  12.         double compConsumption = 125.90;
  13.         int totalConsumption = 0;
  14.         if (time.Hour >= 14 && time.Hour <= 18)
  15.         {  double noon = compConsumption * 2 + lampConsumption * 2;
  16.             totalConsumption = (int)(noon * flatsInDorms);
  17.         }
  18.         else if (time.Hour >= 19 && time.Hour <= 23)
  19.         {   double afterNoon = lampConsumption * 7 + compConsumption * 6;
  20.             totalConsumption = (int)(afterNoon * flatsInDorms);
  21.         }
  22.         else if (time.Hour >= 0 && time.Hour <= 8)
  23.         {   double midnight = compConsumption * 8 + lampConsumption;
  24.             totalConsumption = (int)(midnight * flatsInDorms);
  25.         }
  26.         else{ totalConsumption = 0;} Console.WriteLine("{0} Watts", totalConsumption);
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment