Advertisement
tutzy

Electricity

Apr 2nd, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.81 KB | None | 0 0
  1. //In the "Students Town" each flat in the dorms has 8 lamps, each consuming 100.53 Watts (2 in the kitchen, 3 in the living-room, 1 in the bathroom, 1 in the bedroom and 1 in the lumber-room). Additionally each flat has 8 computers, each consuming 125.90 Watts (1 in the kitchen, 2 in the living-room, 1 in the bathroom, 3 in the bedroom and 1 in the lumber-room). The lamps and computers in each flat always operate in a strict schedule every day:
  2. //•   From 14:00 to 18:59  2 lamps + 2 computers are running
  3. //•   From 19:00 to 23:59  7 lamps + 6 computers are running
  4. //•   From 00:00 to 08:59  1 lamp + 8 computers are running
  5. //Write a program to calculate how many Watts is the total power consumption of the dorms at given time of the day. You will be given the number of floors in the dorms and the number of flats at each floor that operate in the specified time.
  6.  
  7. //Input
  8. //The input data should be read from the console. It consists of exactly 3 lines:
  9. //•   The first line holds the number of floors – floors.
  10. //•   The second line holds the number of flats at each floor – flats.
  11. //•   The third line holds the time of the day in format hh:mm – time.
  12. //The input data will always be valid and in the format described. There is no need to check it explicitly.
  13.  
  14. //Output
  15. //Print at the console the total power consumption in format "X Watts" where X is the total power consumption. Truncate down the result to the nearest whole number.
  16.  
  17. using System;
  18.  
  19. class Electricity
  20. {
  21.     static void Main()
  22.     {
  23.         int floors = int.Parse(Console.ReadLine());
  24.         int flats = int.Parse(Console.ReadLine());
  25.         double allFlats = floors * flats;
  26.         double aa = 0;
  27.         double bb = 0;
  28.         double firstCase = (2 * 100.06) + (2 * 125.90);//
  29.         double secondCase = (7 * 100.06) + (6 * 125.90);
  30.         double thirdCase = (1 * 100.06) + (8 * 125.90);
  31.         string[] time = Console.ReadLine().Split(':');
  32.         for (int i = 0; i < time.Length; i++)
  33.         {
  34.             double a = double.Parse(time[0]);
  35.             aa = a;
  36.  
  37.             double b = double.Parse(time[1]);
  38.             bb = b;
  39.         }
  40.        
  41.             if (aa >= 14 && aa <= 18 && bb >= 0 && bb <= 59)
  42.             {
  43.                 double sum1 = firstCase * allFlats;
  44.                 Console.WriteLine(sum1);
  45.             }
  46.             else if(aa >= 19 && aa <= 23 && bb >= 0 && bb <= 59)
  47.             {
  48.                 double sum2 = secondCase * allFlats;
  49.                 Console.WriteLine(sum2);
  50.             }
  51.             else if(aa >= 0 && aa <= 8 && bb >= 0 && bb <= 59)
  52.             {
  53.                 double sum3 = thirdCase * allFlats;
  54.                 Console.WriteLine(sum3);
  55.             }
  56.             else
  57.             {
  58.                 Console.WriteLine(0);
  59.             }
  60.  
  61.         }
  62.  
  63.  
  64.  
  65.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement