Advertisement
dragonbs

The Biscuit Factory

Feb 19th, 2023
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. int biscuitsPerDayPerOneWorker = int.Parse(Console.ReadLine());
  2. int allWorkersinFactory = int.Parse(Console.ReadLine());
  3. int competitionFactory = int.Parse(Console.ReadLine());
  4.  
  5. double myProductionPerDay = 0;
  6. double totalProduction = 0;
  7. double differenceBetweenFactorys = 0;
  8. double percentDifference = 0;
  9.  
  10. for (int i = 0; i < 30; i++)
  11. {
  12.     myProductionPerDay = biscuitsPerDayPerOneWorker * allWorkersinFactory;
  13.  
  14.     if (i % 3 == 0)
  15.     {
  16.         myProductionPerDay = Math.Floor(myProductionPerDay * 0.75);
  17.     }
  18.     totalProduction += myProductionPerDay;
  19. }
  20.  
  21. Console.WriteLine($"You have produced {totalProduction} biscuits for the past month.");
  22.  
  23. if (totalProduction > competitionFactory)
  24. {
  25.     differenceBetweenFactorys = totalProduction - competitionFactory;
  26.     percentDifference = differenceBetweenFactorys / competitionFactory * 100;
  27.     Console.WriteLine($"You produce {percentDifference:f2} percent more biscuits.");
  28. }
  29. else
  30. {
  31.     differenceBetweenFactorys = competitionFactory - totalProduction;
  32.     percentDifference = differenceBetweenFactorys / competitionFactory * 100;
  33.     Console.WriteLine($"You produce {percentDifference:f2} percent less biscuits.");
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement