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:
days – time that need worker A to finish job;
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 =
B’s 1 hour’s work =
(A + B)’s 1 hour’s work:
Both A and B will finish the work in time
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/
Comments