HW4 #1 - total_items = sum(output) fprintf('Total Items...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 %Engineering 6, Spring 2004, Problem 4.1 %Ryan Uy, 2509 %Section B05, Tues. 3-4 % Worker % 1 2 3 4 5 % Hourly wage 5.00 5.50 6.50 6.00 6.25 % Hours worked 39 43 37 51 45 % Output (no.of items) 1050 900 1000 1250 1100 %Set vector arrays equal to scalar values worker = [1 2 3 4 5] wage = [5.00 5.50 6.50 6.00 6.25] hours = [39 43 37 51 45] output = [1050 900 1000 1250 1100] % a) Display to the nearest cent, how much each worker earned in the week %Weekly wage = hourly wage * hours worked in the week weeks_wage = wage .* hours %Convert to matrix array with worker number and week's wage for each num_wage = [worker weeks_wage] fprintf('Worker Number %.0f earned $%.2f in the week\n', num_wage) disp(' ') %newline % b) Display total salary amount paid out %This is found by adding all workers' week's wage total_salary = sum(weeks_wage) fprintf('Total Salary: $%.2f\n', total_salary) disp(' ') %newline % c) Display total number of items made %This is found by adding up the output for each worker
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: total_items = sum(output) fprintf('Total Items Made: %.0f\n', total_items) disp(' ') %newline % d) Display the average cost to produce one item %This is found by dividing the total salary paid out by the total number of items fprintf('The average cost to produce one item is $%.3f\n', total_salary/total_items) disp(' ') %newline % e) Display the number of hours it takes to produce one item on average %This is found by dividing the total hours worked by the number of items made total_hours = sum(hours) fprintf('The average time to produce one item is %.3f hours\n', total_hours/total_items) disp(' ') %newline % f) Calculate and display the efficiency of each worker %This is defined as output divided by hours worked efficiency = output ./ hours %Convert to matrix array with worker number and week's wage for each num_efficiency = [worker efficiency] Sheet1 Page 2 fprintf('Efficiency for worker %.0f: %.1f items/hour\n', num_efficiency)...
View Full Document

This note was uploaded on 01/22/2011 for the course ENG 006 taught by Professor Lagerstrom during the Spring '06 term at UC Davis.

Page1 / 2

HW4 #1 - total_items = sum(output) fprintf('Total Items...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online