TASK 2: "GROUP OF WORKERS" - SOLUTION
Explanation:
If n workers complete the work in a certain time s, then with more workers (n+m) the work will be completed proportionally less as many times as the number of workers has increased, i.e. (n+m) / n times. For example, if n= 10 and m=5, the number of workers is increased from 10 to 15, i.e. 15/10=1.5 times. The same work will then be completed in 1.5 times less time (inverse proportionality). So, the proportion:
t : s= n : (n+m), from here
t*(n+m)=s*n, and finally
t=s*n/(n+m)
t*(n+m)=s*n, and finally
t=s*n/(n+m)
A group of workers - a solution in the C programming language
#include <stdio.h>
using namespace std;
int main()
{
int n,m; // n-number of workers at the beginning, m-number of added workers
double s,t; //s- Time it takes n workers to finish the job
//t- Time it takes n + m workers to complete the same job
scanf("%d%lf%d", &n, &s, &m); //Reading
/ * t: s = n: (n + m) * / / * proportion * /
/ * t = n * s / (n + m) * // * solution of proportion * /
t=n*s/(n+m); // time to n + m workers, obtained by proportion
printf("%.2f",t); // Print results
return 0;
}
using namespace std;
int main()
{
int n,m; // n-number of workers at the beginning, m-number of added workers
double s,t; //s- Time it takes n workers to finish the job
//t- Time it takes n + m workers to complete the same job
scanf("%d%lf%d", &n, &s, &m); //Reading
/ * t: s = n: (n + m) * / / * proportion * /
/ * t = n * s / (n + m) * // * solution of proportion * /
t=n*s/(n+m); // time to n + m workers, obtained by proportion
printf("%.2f",t); // Print results
return 0;
}
A group of workers - a solution in the programming language JAVA
public static void main(String[] args) {
Scanner ucitavac = new Scanner(System.in);
int n, m; // n-number of workers at the beginning, m-number of added workers
double s, t; //s- time required for n workers to complete the job
//t- time required for n+m workers to complete the same job
//učitavanje
System.out.println("Enter the initial number of workers n=?");
n = ucitavac.nextInt();
System.out.println("Enter the additional number of workers m=?");
m = ucitavac.nextInt();
System.out.println("Enter the time it takes n workers to complete the job");
s = ucitavac.nextInt(); //end of loading
/*t:s=n:(n+m)*/ /*proportion*/
/* t=n*s/(n+m)*//* proportion solution*/
t = n * s / (n + m); // time to n+m workers, obtained by proportion
System.out.printf("%.2f", t); //Print the results
}
Scanner ucitavac = new Scanner(System.in);
int n, m; // n-number of workers at the beginning, m-number of added workers
double s, t; //s- time required for n workers to complete the job
//t- time required for n+m workers to complete the same job
//učitavanje
System.out.println("Enter the initial number of workers n=?");
n = ucitavac.nextInt();
System.out.println("Enter the additional number of workers m=?");
m = ucitavac.nextInt();
System.out.println("Enter the time it takes n workers to complete the job");
s = ucitavac.nextInt(); //end of loading
/*t:s=n:(n+m)*/ /*proportion*/
/* t=n*s/(n+m)*//* proportion solution*/
t = n * s / (n + m); // time to n+m workers, obtained by proportion
System.out.printf("%.2f", t); //Print the results
}