elena1234

BiscuitsFactory-Math.Floor()

Oct 11th, 2020 (edited)
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.67 KB | None | 0 0
  1. using System;
  2.  
  3. namespace BiscuitsFactory
  4. {
  5.     class MainClass
  6.     {
  7.         public static void Main()
  8.         {
  9.             int biscuitsPerDayPerWorker = int.Parse(Console.ReadLine());
  10.             int countOfWorkers = int.Parse(Console.ReadLine());
  11.             int anotherFactoryProductionFor30Days = int.Parse(Console.ReadLine());
  12.             double myProductionFor30days = 0;
  13.             double dailyProduction = Math.Floor((double)biscuitsPerDayPerWorker * countOfWorkers);//must add Math.Floor in the beginning for correct result
  14.             double dailyProductionEveryThirdDay =Math.Floor((double) dailyProduction -  (0.25 * dailyProduction));
  15.  
  16.             for (int day = 1; day <=30; day++)
  17.             {
  18.  
  19.                 if (day % 3 != 0)
  20.                 {
  21.                     myProductionFor30days += dailyProduction;
  22.                 }
  23.  
  24.                 else if (day % 3 == 0)
  25.                 {
  26.                     myProductionFor30days += dailyProductionEveryThirdDay;
  27.                 }
  28.             }
  29.             Console.WriteLine($"You have produced {myProductionFor30days} biscuits for the past month.");
  30.             if (myProductionFor30days > anotherFactoryProductionFor30Days)
  31.             {
  32.                 Console.WriteLine($"You produce { Math.Floor(myProductionFor30days-anotherFactoryProductionFor30Days)/anotherFactoryProductionFor30Days*100:F2} percent more biscuits.");
  33.             }
  34.             else
  35.             {
  36.                 Console.WriteLine($"You produce {Math.Floor(anotherFactoryProductionFor30Days-myProductionFor30days)/anotherFactoryProductionFor30Days*100:F2} percent less biscuits.");
  37.             }
  38.          }
  39.        }
  40.     }
  41.  
  42.  
  43.  
Add Comment
Please, Sign In to add comment