aggressiveviking

Untitled

Feb 20th, 2020
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _11.HappyCatParking
  4. {
  5.     class HappyCatParking
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int days = int.Parse(Console.ReadLine());
  10.             int hours = int.Parse(Console.ReadLine());
  11.  
  12.             double totalPrice = 0;
  13.  
  14.             for (int day = 1; day <= days; day++)
  15.             {
  16.                 double priceDay = 0;
  17.  
  18.                 for (int hour = 1; hour <= hours; hour++)
  19.                 {
  20.                     if (day % 2 == 0 && hour % 2 != 0)
  21.                     {
  22.                         priceDay = priceDay + 2.50;
  23.                     }
  24.                     else if (day % 2 == 0 && hour % 2 == 0)
  25.                     {
  26.                         priceDay = priceDay + 1;
  27.                     }
  28.                     else if (day % 2 != 0 && hour % 2 == 0)
  29.                     {
  30.                         priceDay = priceDay + 1.25;
  31.                     }
  32.                     else if (day % 2 != 0 && hour % 2 != 0)
  33.                     {
  34.                         priceDay = priceDay + 1;
  35.                     }
  36.                 }
  37.  
  38.                 totalPrice += priceDay;
  39.  
  40.                 Console.WriteLine($"Day: {day} - {priceDay:f2} leva");
  41.             }
  42.          
  43.             Console.WriteLine($"Total: {totalPrice:f2} leva");
  44.  
  45.  
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment