14440127 PS 1- Solutions

14440127 PS 1- Solutions - 14:440:127. Introduction to...

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

View Full Document Right Arrow Icon
14:440:127. Introduction to Computers for Engineers PROBLEM SET 1 Solutions, Fall 2008. 1. Recitation 2, #4 Use Matlab to calculate the following. Let x = 9.2; z = 8.8 x = 9.2; z = 8.8; x*z^3 – ((2*z)/(3*x))^(z/(2*x))*x*z^3 – ((2*z)/(3*x))^(z/(2*x)) ans = 1.2130e+003 2. Recitation 2, #10 A worker is paid $20/hour (up to 40 hours), and 50% more for overtime. Write a matlab script file (m-file) to calculate the worker’s pay. Don’t forget to create a variable hours that contains the number of hours he/she worked. Test this for 20 hours, 40 hours, 41 hours, and 60 hours. hours = 41; % or whatever you want it to be if(hours>40) pay = 40*20 + (hours-40)*30 else pay = hours*20 end 3. Recitation 2, #11 Write an m-file that displays whether a number is odd or even. Test your code. x = 15; % or whatever you want if(rem(x,2)) disp(‘odd’) else disp(‘even’) end 4. Recitation 2, #15 Assign the variable x to be some number. Write an if statement that displays whether or not x is an integer. (hint for one approach: try comparing x with the result of rounding x .) x = 22.4; % or whatever you want if( round(x) == x) disp(‘x is an integer’) else disp(‘x is not an integer’) end 5. Recitation 2, #21 A year is a leap year if divisible by 4 but not by 100. If a year is divisible by 4 and by 100, it is
Background image of page 1

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

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

This note was uploaded on 02/29/2012 for the course 440 127 taught by Professor Blase during the Fall '09 term at Rutgers.

Page1 / 4

14440127 PS 1- Solutions - 14:440:127. Introduction to...

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