Homeworks

  (Software Development Practices) (Spring 2001)

 

Home
Lecture Notes
Textbook
Homeworks
Exams
Resources

Late Policy:

If for some reason you can't meet the due date, your work will still be accepted up to 3 work days past the due date but with some penalty:

10 points, out of  100,  will be deducted from the grade of an assignment for the first late day.

Penalty will double for every day of late submission thereafter. Weekends will count as one day.

Because of the compressed time schedule, late submissions are strongly discouraged. 

Submit late homeworks through e-mail as one compressed zip file, clearly indicating its content in the subject line. Also submit a hard-copy (on paper) to instructor in the first lecture following your submission.  

Warning:

Be prepare to spend 8-10 hours for each homework every two weeks. 

Guidelines to follow:

1. Follow the good programming practices given in the book. Especially, properly indent your program, write comments where necessary, follow the convention mentioned in the class in choosing your identifier names.

2. Include your name, class, student id, homework number and section id on the first page. 

3. Include the question number in the identification comment at the top of the program. 

3. Use paper conservatively. You may download Fineprint driver (at www.fineprint.com) and fit  four printout pages (or two pages if your printer's print quality is poor) in each page.

Caution: It is not very difficult for a professional to detect cheaters. So if you have done the homework with someone else indicate your partner at the beginning of the code. If I catch any unmentioned partnerships, I will deal them separately. 

Note: I will choose and grade only some of the exercises. But if you have not answered any of the questions,  you will automatically loose some  points for each unanswered question.

Deliverables:

1. Submit printouts of your code  and at least one sample run of your program on paper. 
2. Also turn in your program on a diskette so that the instructor can compile and run your program. 
3. You should also describe your programming environment on a separate page. This page should include: 

Operating System: UNIX (Solaris, Digital, etc.), LINUX, Windows (95, 98, 98se, NT, 2000, ME), etc.
Compiler: Turbo C++, Borland C++ Compiler 5.5,  Borland C++ Builder 5, Visual C++ 6, GNU C Compiler 2.0, etc.

 

Homework Assignment - 5  (Due to May 23) (Solutions)

Write a class called Rationalfor performing arithmetic with fractions. 

Use integer variables to represent private data of the class -- the numerator and the denominator. Provide a constructor function that enables an object of this class to be initialized when it is declared. The constructor should contain default values in case no initializers are provided and should store the fraction in reduced form (i.e., the fraction 
    2
   ----
    4 
would be stored in the object as 1 in the numerator and 2 in the denominator). It should also avoid negative denominators. 

Hint: You should write a utility member function called reduce.

a) Overload the addition, subtraction, multiplication, and division operators for this class. The result should be stored in reduced form.

Hint: The operators should work as usual, they should not change the values of input operands.

b) Write a friend function to print Rational numbers in the form a/b where a is the numerator and b is the denominator. Overload << operator for this purpose.

c) Write a friend  function to input  Rational numbers in the form a/b where a is the numerator and b is the denominator. Overload >> operator for this purpose.

d) Provide a member function for printing  Rational numbers in floating point format. 

e) Overload the relational and equality operators for this class.

f) Write a driver program (i.e., a main function) to test each member function of your class. Your program should at least contain the following statements:

Rational a, b(5), c(6,2), d, e;

Instructions:

You may form 2-person working groups in this assignment. In this case submit a single set of solutions but clearly mark the name of participants in the front page. (If you form larger groups, a -20 points will be deducted from your total score for each extra person.)

Homework 5 Grading Policy:

-20 Arguments to functions are not Rational numbers but individual basic data types.
-5 each: missing overloaded functions: +, -, /, *
-5 each: missing friend functions: << or >>
-5 Problems about initializing object with default values

 

Homework Assignment - 4  (Due to May 2) (Solutions)

You may form 2-person working groups in this assignment. In this case submit a single set of solutions but clearly mark the name of participants in the front page. (If you form larger groups, a -20 points will be deducted from your total score for each extra person.)

Do the following exercises in the textbook:

7.19, 15.15, 15.20, 16.8  (Numbers are from the 2nd edition of the textbook - If you have the 3rd edition, make sure you solve  the same questions.)

Exercises are given below:

7.19) (A Computer Simulator) It may at first seem outrageous, but  ...

Save each of the SML program you wrote in Exercise 7.18 in a separate file. Your simulator should ask the user to enter the name of the SML program file and then read in and process the  program in the file. 

15.15) Write a complete C++ program with the three alternate function described below that each simply add 1 to the variable count defined in main. Then compare and contrast the three alternate approaches. These three functions are

a) Function add1ByValue that passes a copy of count call by value, adds 1 to the copy, and returns the new value.

a) Function add1ByPointer that passes access to variable count via simulated call by reference using pointers, and uses the dereferencing operator * to add 1 to the original copy  of count in main. 

a) Function add1ByReference that passes a count with true call by reference via a reference parameter, and adds 1 to the original copy   of count through its alias (i.e., the reference parameter).

15.20) Write a program that uses a function template called max   to determine the larger of three arguments. Test the program using integer, character, and floating-point number pairs. Plus read the section on macros in the textbook and write a preprocessor macro for doing the same thing.

16.8) Modify the Time class of Fig. 16.10 (you may use the class  given in lecture notes) to include a tick member function that increments the time stored in a Time object by one second. The Time object should always remain in a consistent state. Write a driver program that tests the tick member function in a loop that prints the time in standard format during each iteration of the loop to illustrate that the tick member function works correctly. Be sure to test the following cases:

a) Incrementing into the next minute

b) Incrementing into the next hour

c) Incrementing into the next day (i.e., 11:59:59 PM to 12:00:00 AM).

Homework Assignment - 3  (Due to April 18) (Solutions)

You may form 2-person working groups in this assignment. In this case submit a single set of solutions but clearly mark the name of participants in the front page. (If you form larger groups, a -20 points will be deducted from your total score for each extra person.)

Do the following exercises in the textbook:

7.12, 7.18, 10.8, 10.13, 10.14 (Numbers are from the 2nd edition of the textbook - If you have the 3rd edition, make sure you solve  the same questions.)

Excerpts of the selected exercises are given below:

7.12) Modify the program in Fig.7.24 so that the card dealing function  ...

7.18) (Machine Language Programming) Let us create a computer ...

10.8) Create a union integer with members char c, short s, . ...

10.13) The left shift operator can be used to pack  ...

10.14) Using the right shift operator, the bitwise AND operator and a mask  ...

Homework Assignment - 2  (Due to March 30) (Solutions)

You may form 2-person working groups in this assignment. In this case submit a single set of solutions but clearly mark the name of participants in the front page. (If you form larger groups, a -20 points will be deducted from your total score for each extra person.)

Do the following exercises in the textbook:

6.11, 6.19, 6.22, 8.6, 8.8, 8.10, 8.14  (Numbers are from the 2nd edition of the textbook - If you have the 3rd edition, make sure you solve  the same questions.)

Excerpts of the selected exercises are given below:

6.11) The bubble sort presented in Fig. 6.15 is inefficient for large arrays. ...

6.19) Write a C program that simulates the rolling of two dice. ...

6.22) Use a double-subscripted array to solve the following problem. ...

8.6) Write a program that inputs a line of text with function gets into character array s[100]. ...

8.8) Write a program that inputs 4 strings that represent floating-point values, ...

8.10) Write a program that uses function strncmp to compare two strings input by the user. ...

8.14) Write a program that inputs a telephone number as a string in the form (555) 555-5555. ...

Deliverables:

1. Submit printouts of your code  and at least one sample run of your program on paper. 
2. Also turn in your program on a diskette so that the instructor can compile and run your program. 
3. You should also describe your programming environment on a separate page. This page should include: 

Operating System: UNIX (Solaris, Digital, etc.), LINUX, Windows (95, 98, NT, 2000), etc.
Compiler: Borland C++ Compiler 5.5,  Borland C++ Builder 5, Visual C++ 6, GNU C Compiler 2.0, etc.

Homework Assignment - 1 Make-up  (Due April 25) 

(Only for the  students who registered late)

Do  exercise 4.17 in the textbook:

Submit printouts of your code  and at least one sample run of your program on paper. 

Homework Assignment - 1  (Due March 16) (Solutions)

Do the following exercises in the textbook:

2.13, 2.14, 2.15, 3.13, 3.18, 3.21, 4.9, 4.10, 4.11, 4.31.

Submit printouts of your code  and at least one sample run of your program on paper. 

Grading policy for homework 1

Homework Assignment - 0  (Due Feb 23) (Solutions)

Computer type  and print out the following information on a piece of A4 paper, and attach a photo of yours. The supplied info will help the instructor to get to know the class.

Note 1: Do not answer any questions that you may feel like an intrusion to your privacy.

Note 2: Your photo will be returned to you by the end of semester.

Name and last name:
Class: a) senior  b) master's
Student No:
E-mail address:
Personal Web page: 
Have you attended English prep. shool at HU?
If you are a master's student, your undergraduate major and university?
Your (undergraduate) CGPA range? a) 2.00-2.49
b) 2.50-2.99
c) 3.00-3.49
d) 3.50-4.00
Where do you stay?  a) with family  
b) in campus  (dormitories)
c) out of campus
Do you have a PC at home?
Do you have a printer at home?
Grades in introductory programming (i.e., PASCAL) courses?
Name and knowledge level (elementary, medium, advanced) of each programming language you know: 
 

 

List of letter grades was turned in to department on June 13th.

Your unclaimed  diskettes will be donated to department.

 

Last updated: 25/07/2001 21:37