Advertisement
dimipan80

Exam July Evening 1. Electricity

Jul 27th, 2014
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.40 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3. using System.Threading;
  4.  
  5. public class Electricity
  6. {
  7.     public static void Main()
  8.     {
  9.         Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  10.         checked
  11.         {
  12.             int floors = int.Parse(Console.ReadLine());
  13.             int flats = int.Parse(Console.ReadLine());
  14.             string givenTime = Console.ReadLine();
  15.  
  16.             string hourStr = givenTime.Remove(givenTime.IndexOf(':'));
  17.             int givenHour = int.Parse(hourStr);                        
  18.  
  19.             int totalFlats = floors * flats;
  20.             double powerLamp = 100.53;
  21.             double powerComputer = 125.90;
  22.             double totalPower = 0;
  23.             if (givenHour >= 14 && givenHour <= 18)
  24.             {
  25.                 totalPower = totalFlats * ((2 * powerLamp) + (2 * powerComputer));
  26.             }
  27.             else if (givenHour >= 19 && givenHour <= 23)
  28.             {
  29.                 totalPower = totalFlats * ((7 * powerLamp) + (6 * powerComputer));
  30.             }
  31.             else if (givenHour >= 0 && givenHour <= 8)
  32.             {
  33.                 totalPower = totalFlats * (powerLamp + (8 * powerComputer));
  34.             }
  35.             else if (givenHour >= 9 && givenHour <= 13)
  36.             {
  37.                 totalPower = 0;
  38.             }
  39.  
  40.             Console.WriteLine("{0} Watts", (int)totalPower);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement