{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

A6soln_ENGR215_F08

# A6soln_ENGR215_F08 - Engineering College of San Mateo ENGR...

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

Engineering ENGR 215 College of San Mateo L. Demsetz Solutions to Assignment 6: More Programming 1. Complete problem 36 on pages 201-202. Just do the work; nothing to turn in. 2. Write a function to use the Babylonia algorithm to find the square root of a number. Your function should take two arguments (n and delta) and return the calculated value of the square root. Submit your code as A6P2.m (with appropriate comments). Paste as comments at the end of the file evidence that you have tested the code thoroughly. function root = A6P2(n, delta) % Precondition: n, delta are positive numbers. % Postcondition: returns positive square root of n to an accuracy of %delta root_old = n/2; root = n/root_old; while (abs(root^2-n) > delta) root_old = (root_old + root)/2; root = n/root_old; end 3. Write the program described in problem 45 on page 204. function total_days = days(year,month,day) total_days = day; for k = 1:month - 1 switch k case {1, 3, 5, 7, 8, 10, 12} total_days = total_days + 31; case {4, 6, 9, 11} total_days = total_days + 30; case 2 total_days = total_days + 28 + leap(year); end end

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

A6soln_ENGR215_F08 - Engineering College of San Mateo ENGR...

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

View Full Document
Ask a homework question - tutors are online