iliya87

01.Electricity

Mar 27th, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2.  
  3. public class Electricity
  4. {
  5.     public 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.  
  11.         int sumWats;
  12.         if (time.Hour >= 14 && time.Hour <= 18)
  13.         {
  14.             // Noon time
  15.             double noonConsumption = (2 * 100.53) + (2 * 125.90);
  16.             sumWats = (int)(noonConsumption * flats * floors);
  17.         }
  18.         else if (time.Hour >= 19 && time.Hour <= 23)
  19.         {
  20.             // Afternoon time
  21.             double afternoonConsumption = (7 * 100.53) + (6 * 125.90);
  22.             sumWats = (int)(afternoonConsumption * flats * floors);
  23.         }
  24.         else if (time.Hour >= 0 && time.Hour <= 8)
  25.         {
  26.             // Midnight time
  27.             double midnightConsumption = (1 * 100.53) + (8 * 125.90);
  28.             sumWats = (int)(midnightConsumption * flats * floors);
  29.         }
  30.         else
  31.         {
  32.             // Any other time --> zero consumption
  33.             sumWats = 0;
  34.         }
  35.  
  36.         Console.WriteLine(sumWats + " Watts");
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment