Advertisement
Alexander_B

Three Brothers

Jan 27th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace DomashnoThreeBrothers
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. // get times of the three brothers and father gone time
  14.  
  15. double TimeNeedToCleanFirstBrother = double.Parse(Console.ReadLine());
  16. double TimeNeedToCleanSecondBrother = double.Parse(Console.ReadLine());
  17. double TimeNeedToCleanThirdBrother = double.Parse(Console.ReadLine());
  18. double TimeGoneFather = double.Parse(Console.ReadLine());
  19.  
  20. // define percent of time for relax
  21.  
  22. double PercentOfTimeForRelax = 15;
  23.  
  24. // calculate cleaning time needed
  25.  
  26. double TimeNeedToCleenAllBrothers = 1 / (1 / TimeNeedToCleanFirstBrother + 1 / TimeNeedToCleanSecondBrother + 1 / TimeNeedToCleanThirdBrother);
  27. double TimeNeedToCleanAllBrothersWithRelax = TimeNeedToCleenAllBrothers + (TimeNeedToCleenAllBrothers * 1.00 * PercentOfTimeForRelax / 100);
  28.  
  29. // deside if the time is enough and print result
  30.  
  31. Console.WriteLine($"Cleaning time: {TimeNeedToCleanAllBrothersWithRelax:F2}");
  32. double TimeDifference = TimeGoneFather-TimeNeedToCleanAllBrothersWithRelax;
  33. if (TimeDifference >= 0)
  34. {
  35. double TimeLeft = Math.Floor(TimeDifference);
  36. Console.WriteLine($"Yes, there is a surprise - time left -> {TimeLeft} hours.");
  37. }
  38. else
  39. {
  40. double TimeNotEnough = Math.Ceiling(TimeDifference*(-1));
  41. Console.WriteLine($"No, there isn't a surprise - shortage of time -> {TimeNotEnough} hours.");
  42. }
  43.  
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement