Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume that two women (A and B) are hired to work on annual contracts. Worker A

ID: 640272 • Letter: A

Question

Assume that two women (A and B) are hired to work on annual contracts. Worker A is offered a salary of $3000 per month ($36,000 total for the year), but worker B is offered a changing pay scale that is defined as follows: For the first month, she is paid a total of $20, the second month this amount is doubled and she will receive $40, the third month $80, the fourth month $160, etc. Worker B is very disappointed because she perceives that her earnings will be substantially less than that of her coworker. To help her through this dilemma, you decide to determine what her total earnings will be at the end of the contract (1 year). While it is possible to determine the amount through a closed form solution, you want to gain experience using a "for" loop. Using this concept write an Mfile program (using a "for" loop) that will determine the total amount ($) that worker B will have earned by the end of the year. In addition, use the program that you have written to determine during which month the wages of worker B will exceed that of worker A.

Explanation / Answer

var = 20;
total=20;
i = 0;
for a = 2:12
var=2*var;
total=total+var;
if var >= 3000
if i==0
fprintf('In %dth month monthly salary of B exceeds A',a);
i++;
end
end
end
      fprintf(' Total salary of B at end of year is : $%d ', total);
end

o/p: