Programming Assignments for Math 218


Make sure you save your programs in your folder in P drive for each lab before the deadline. Having it elsewhere (e.g. in your H drive) does not help. Do NOT modify after the deadline.


Assignment 2: Due 11:59 pm, Tue Jan 27 (This lab is also a review from the first programming course)

Part I: is on inheritance and described here

Part II: In Programming Example of section 2, Complex numbers are implemented. Extend the definition of the class complexType given in the book by overloading the following operators:

- : for subtraction

/ : for division

~ : complex conjugation

! : absolute value

(See exercises 12-15 for more detailed description). Notice that - and / are binary operators whereas ~ and ! are unary operators.

Implement - and / as non-member operators but ~ and ! as member operators. Use the pointer this in the implementations of ~ .

You may use the files given in the book, but make sure you modify the test program so that you throughly test the new operations you define.

Part III: (For practice, not for grade) Do programming project 4 on page 125 in 2 ways: First using inheritence as described in the book. Second using composition where the class circleType includes the class pointType. You may use the test program in the class folder FILESFORLABS\Lab2 (for the inheritance version), or you can write a test program similar to it.


Assignment 1: Due 11:59 pm, Tue Jan 20 (This is a review from the first programming course)

Do programming exercises 1 and 6 at the end of chapter 1. Writing a reasonable test program with good user interface (e.g. letting the user repeat the computation) is an important part of the assignment (and this is a default requirement in all future assignments as well). For exercise 1, you can assume that the input for Roman numeral is a legal string. Your program should allow the user to enter/test more Roman numerals than given in the text.

Also, write up solutions for problems 6-8 in the worksheet "Practice with Big-O Notation" and turn them in class on Tuesday, Jan 20.