Advertisement
fbinnzhivko

01.00 Electricity

Apr 16th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     private static object dateTime;
  5.     static void Main()
  6.     {
  7.         double lampConsumption = 100.53;
  8.         double compConsumption = 125.90;
  9.         int floors = int.Parse(Console.ReadLine());
  10.         int flats = int.Parse(Console.ReadLine());
  11.         string text = Console.ReadLine();
  12.         DateTime time = DateTime.Parse(text);
  13.  
  14.         int totalFlats = floors * flats;
  15.         int totalComputars = 0;
  16.         int totalLamps = 0;
  17.        
  18.         if (time >= Convert.ToDateTime("14:00") && time <= Convert.ToDateTime("18:59"))
  19.         {
  20.             totalComputars = totalFlats * 2;
  21.             totalLamps = totalFlats * 2;
  22.         }
  23.         else if (time >= Convert.ToDateTime("19:00") && time <= Convert.ToDateTime("23:59"))
  24.         {
  25.             totalComputars = totalFlats * 6;
  26.             totalLamps = totalFlats * 7;
  27.         }
  28.         else if (time >= Convert.ToDateTime("00:00") && time <= Convert.ToDateTime("08:59"))
  29.         {
  30.             totalComputars = totalFlats * 8;
  31.             totalLamps = totalFlats * 1;
  32.         }
  33.         double result = Math.Floor(totalLamps * lampConsumption + totalComputars * compConsumption);
  34.  
  35.         Console.WriteLine("{0} Watts", result);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement