zh_stoqnov

Electricity

Nov 2nd, 2014
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Electricity
  4. {
  5. class Electricity
  6. {
  7. public static void Main(string[] args)
  8. {
  9. int floors = int.Parse(Console.ReadLine());
  10. int flats = int.Parse(Console.ReadLine());
  11. string timeStr = Console.ReadLine();
  12. DateTime time = Convert.ToDateTime(timeStr);
  13. int hour = time.Hour;
  14. int minutes = time.Minute;
  15. double lampConsumption = 100.53;
  16. double pcConsumption = 125.9;
  17. double flatsAll = (double)floors * flats;
  18. int consumption = 0;
  19. if(hour >= 14 && hour <= 18 && minutes >= 00 && minutes <= 59)
  20. {
  21. consumption = (int)Math.Truncate(flatsAll * (2 * lampConsumption + 2 * pcConsumption));
  22. Console.WriteLine(consumption + " " + "Watts");
  23. }
  24. else if(hour >= 19 && hour <= 23 && minutes >= 00 && minutes <= 59)
  25. {
  26. consumption = (int)Math.Truncate(flatsAll * (7 * lampConsumption + 6 * pcConsumption));
  27. Console.WriteLine(consumption + " " + "Watts");
  28. }
  29. else if(hour >= 00 && hour <= 08 && minutes >= 00 && minutes <= 59)
  30. {
  31. consumption = (int)Math.Truncate(flatsAll * (1 * lampConsumption + 8 * pcConsumption));
  32. Console.WriteLine(consumption + " " + "Watts");
  33. }
  34. else
  35. {
  36. consumption = (int)Math.Truncate(flatsAll * (0 * lampConsumption + 0 * pcConsumption));
  37. Console.WriteLine(consumption + " " + "Watts");
  38. }
  39.  
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment