Advertisement
felix_de_suza

_1_Electricity

Sep 6th, 2014
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 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. string timeString = Console.ReadLine();
  10. int flatsInDorms = floors * flats;
  11. double compConsumption = 100.53;
  12. double lampConsumption = 125.90;
  13. double totalConsumption = 0;
  14. DateTime t1start = DateTime.Parse("2012/12/12 14:00:00.000");
  15. DateTime t1end = DateTime.Parse("2012/12/12 18:59:00.000");
  16. DateTime t2start = DateTime.Parse("2012/12/12 19:00:00.000");
  17. DateTime t2end = DateTime.Parse("2012/12/12 23:59:00.000");
  18. DateTime t3start = DateTime.Parse("2012/12/12 00:00:00.000");
  19. DateTime t3end = DateTime.Parse("2012/12/12 08:59:00.000");
  20. DateTime time = DateTime.Parse(timeString, System.Globalization.CultureInfo.CurrentCulture);
  21. if (time.TimeOfDay > t1start.TimeOfDay && time.TimeOfDay < t1end.TimeOfDay)
  22. {
  23. totalConsumption = (compConsumption * 2 + lampConsumption * 2) * flatsInDorms;
  24. }
  25. else if (time.TimeOfDay > t2start.TimeOfDay && time.TimeOfDay < t2end.TimeOfDay)
  26. {
  27. totalConsumption = (compConsumption * 7 + lampConsumption * 6) * flatsInDorms;
  28. }
  29. else if (time.TimeOfDay > t3start.TimeOfDay && time.TimeOfDay < t3end.TimeOfDay)
  30. {
  31. totalConsumption = (int)(compConsumption * 8 + lampConsumption) * flatsInDorms;
  32. }
  33. else
  34. {
  35. totalConsumption = 0;
  36. }
  37. Console.WriteLine("{0} Watts", Math.Floor(totalConsumption));
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement