Homework 4 UCR CS10: Introduction to Computer Science Spring Quarter 2004, Lecturer: Kris Miller Due Wednesday, May 5 before 8:00pm by web turnin. ------------------------------------------------------------------------------- Turnin: Turnin this assignment to the folder, hw4, using the electronic turnin linked to from the class webpage. For homeworks only, you may turnin .doc (Microsoft Word) or .txt (Notepad) files. You may also turnin the homework as a .cc or .cpp (C++ source) file. Be sure to turn it into the correct folder. At best, you will be penalized 20%. At worst, your homework may not be graded at all. ------------------------------------------------------------------------------- Note: Collaboration policy for this homework assignment Collaboration on this homework is strongly ENCOURAGED. The homework is intended for practice, not assessment -- most people who turn in decent work should get most if not all points for this assignment. Forming study groups is strongly encouraged. You shouldn't simply copy answers from any source -- each other, the book, the web, other books, previous solutions, etc. But you can certainly discuss how to solve the problems, look over each others solutions and help "debug" them, compare answers and redo problems if you determine your answer is wrong, and most importantly, explain concepts related to the problems and solutions. ------------------------------------------------------------------------------- 0. For 1 point bonus (20%), enter the names (first and last name) of the CS10 students you collaborated on this homework with. 1. Self-test Exercise #3-19 (Chapter 3, Exercise #19) 2. Self-test Exercise #4-1 (Chapter 4, Exercise #1) 3. Self-test Exercise #4-4 4. Self-test Exercise #4-7 5. Self-test Exercise #4-8 6. Self-test Exercise #4-9 7. Self-test Exercise #4-11 8. Self-test Exercise #4-13 9. Self-test Exercise #4-14 Solutions to Self-test Exercises in the back of each chapter. 10. CodeMate Problem #8 from Chapter 4 void convertToPounds(double kilograms, double grams, double& pounds, double& ounces) { double total_weight_kilograms, total_weight_pounds; // converts the entire weight entered by user to just kilograms total_weight_kilograms = kilograms + (grams / gramsPerKilogram); // converts the entire weight to pounds total_weight_pounds = total_weight_kilograms * poundsPerKilogram; // removes fractional part of pounds (floor in cmath library) pounds = floor(total_weight_pounds); // converts the leftover fractional part to ounces ounces = (total_weight_pounds - pounds) * ouncesPerPound; }