Advertisement
Niicksana

Three brothers

Dec 10th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 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 _2.Three_brothers
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // Exam - 17 September 2017
  14.             double firstBrother = double.Parse(Console.ReadLine());
  15.             double secondBrother = double.Parse(Console.ReadLine());
  16.             double thirdBrother = double.Parse(Console.ReadLine());
  17.             double totalTime = double.Parse(Console.ReadLine());
  18.  
  19.             double time = (1 / (1 / firstBrother + 1 / secondBrother + 1 / thirdBrother)) +
  20.                           ((1 / (1 / firstBrother + 1 / secondBrother + 1 / thirdBrother)) * 0.15);
  21.             double timeLeft = (totalTime - time);
  22.  
  23.             Console.WriteLine("Cleaning time: {0:f2}", time);
  24.             if (timeLeft > 0)
  25.             {
  26.                 Console.WriteLine("Yes, there is a surprise - time left -> {0} hours.", Math.Floor(timeLeft));
  27.             }
  28.  
  29.             else
  30.             {
  31.                 Console.WriteLine("No, there isn't a surprise - shortage of time -> {0} hours.", Math.Ceiling(time - totalTime));
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement