Homework 6 solution UCR CS10: Introduction to Computer Science Spring Quarter 2004, Lecturer: Kris Miller Due Wednesday, May 19 before 8:00pm by web turnin. ------------------------------------------------------------------------------- Turnin: Turnin this assignment to the folder, hw6, 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 #5-19 (Chapter 5, Exercise #19) 2. Self-test Exercise #5-20 3. Self-test Exercise #5-22 4. Self-test Exercise #5-25 5. Self-test Exercise #5-26 6. Self-test Exercise #5-27 7. Self-test Exercise #5-28 8. Self-test Exercise #5-29 9. Self-test Exercise #6-1 ***Answers to Self-test Exercise are in the back of each chapter*** 10. Given the following structure: struct BasketballTeam { string name; int number_of_wins; double points_per_game; }; what will be the output produced by the following code? BasketballTeam team1, team2; team1.name = "Los Angeles Lakers"; team1.number_of_wins = 56; team1.points_per_game = 98.2; team2.name = "San Antonio Spurs"; team2.number_of_wins = 57; team2.points_per_game = 91.5; if (team1.number_of_wins > team2.number_of_wins) { cout << team1.name; } else { cout << team2.name; } cout << " have homecourt advantage.\n"; if (team1.points_per_game > team2.points_per_game) { cout << team1.name; } else { cout << team2.name; } cout << " will win the series.\n"; ***Answer*** San Antonio Spurs have homecourt advantage. Los Angeles Lakers will win the series.