Question #44782

Worker A can do a job in 15 days while worker B can do the same job in 20 days. Write a program to calculate the total number of days required to finish the work if both the workers work simultaneously.
1

Expert's answer

2014-08-08T04:51:57-0400

Answer on Question #44782 – Programming - C#

Worker A can do a job in 15 days while worker B can do the same job in 20 days. Write a program to calculate the total number of days required to finish the work if both the workers work simultaneously.

Solution:

t1=15t_1 = 15 days – time that need worker A to finish job;

t2=20t_2 = 20 days – time that need worker B to finish job;

T

- number of days required to finish the work if both the workers work simultaneously

A’s 1 hour’s work = 1t1\frac{1}{t_1}

B’s 1 hour’s work = 1t2\frac{1}{t_2}

(A + B)’s 1 hour’s work:


t=1t1+1t2t = \frac{1}{t_1} + \frac{1}{t_2}


Both A and B will finish the work in time


T=1t=11t1+1t2=1115+120=8.57 dayT = \frac{1}{t} = \frac{1}{\frac{1}{t_1} + \frac{1}{t_2}} = \frac{1}{\frac{1}{15} + \frac{1}{20}} = 8.57 \text{ day}


Code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Workers
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("How many days Worker A need to finish job?");
            double time1 = Double.Parse(Console.ReadLine());
            Console.WriteLine("How many days Worker B need to finish job?");
            double time2 = Double.Parse(Console.ReadLine());
            double timeTogether = 1 / (1 / time1 + 1 / time2);
            Console.WriteLine("Number of days required to finish the work if both the workers work simultaneously: {0}", timeTogether);
            Console.ReadLine();
        }
    }
}


http://www.AssignmentExpert.com/

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS