ELE 491 - Software Development Practices - 1
(Fall 2001)

Old Homeworks

Home
Lecture Notes
Textbook
Homeworks
Homework Policies
Exams
TA's Page
README

Homework Assignment - 4  (Due to Dec 12nd ) 

Question 1 will be about implementing a bus reservation system similar to ones posted at  http://www.varan.com.tr (Follow the links to Rezarvasyon ve Bilet Satisi) or http://www.ulusoyotobus.com.tr. (Follow the links to Seferler / Rezervasyon)

You are supposed to write an online reservation system for a bus company, HU Lines.

Assume that you have buses to accommodate 37 passengers each. When a passenger arrives, you need to check the availability of seats by displaying the seat plan:

====================================!
\KAPI 01 05  K 13 17  KAPI 25 29 33 !

\     K  06  K 14 18       26 30 34
!
               
\                                                                 35  !

\     03 E  11 15 19 21 23 27 31 36 !
\     04 E  12 16 20 22 24 28 32 37 !
\===================================!

If a seat is taken, it is marked with a `K` or a `E` to indicate that it has been sold to a woman or a man, correspondingly. You should be careful to seat a female next to another female and a man next to another man unless a group of even number of passengers buy their tickets as a group (in that case you may think of them all male or all female). If the number of persons in a group is odd, they should indicate who will sit alone so that you can mark that seat with the gender of the passenger.

You need to write a function called test() to simulate the arriving of customers to the reservation office. The function should do the following in order:

  1. Randomly determine the exact number of arriving customers. There may be minimum of 20 and maximum of 40 customers. 
  2. Randomly determine if the customer is alone or traveling with a group. With a probability of 60% s/he is alone, 30% s/he is traveling with a companion, and 10% s/he is traveling with two other people.
  3. Randomly determine the gender of the customer who will be seated alone.
  4. Derive the name of the customer by using a counter as a base:  Male Passenger1, Female Passenger1, Female Passenger2, etc.
  5. Print a status message after serving each customer:

Passenger:  M     Assigned to: 35
Passenger:  M M   Assigned to: 34 35
Passenger:  F F M Assigned to: 17 18 19

  1. Print the seat plan after serving every 10th  customer and after serving the last customer.
  2. Once the last customer has been served, it should print a summary report, indicating the total number of passengers in the bus, and the seat numbers, gender, and names of each passenger.

P.S.You may make assumptions if you need any further information in order to solve the given problem. But you have to write your assumption(s) clearly in your answer sheet.

Question 2 will be about implementing some of the string manipulation functions of Microsoft Word using C. You will be given a text file as input and implement a set of functions in C.  See Format | Change Case, Edit | Copy, Edit | Cut, Edit | Paste, Edit | Find, Edit | Replace functions.

You need to write the following functions to do word processing over the input text:

a)     ChangeCase (inputString, startLoc, endLoc) where startLoc and endLoc are the starting index and ending index of the area of interest in the inputString.

b)  EditCopy (inputString, startLoc, endLoc)

c)     EditCut (inputString, startLoc, endLoc)

d)     EditPaste(inputString, pasteString, loc) where pasteString contains the string to be pasted.

e)     EditFind(inputString, searchString) searchString is the string that is sought in the inputString.

f)      EditReplace(inputString, originalString, replacementString) originalString and replacementString are the string that needs to be found in the inputString and to be replaced by the replacementString.

Write a test routine, called test() to check out whether your functions run correctly.

Open notepad and type the following text as is and save this file as input.dat. This will be your input text:

C programs typically go six phases to be executed. These are: edit, preprocess, compile, link, load, and execute. The first phase consists of editing a file. This is accomplished with an editor program. Next, the programmer gives the command to compile the program. The compiler translates the C program into machine language code (also referred to as object code). In a C system, a preprocessor program automatically executes before the translation phase begins. The C preprocessor obeys special commands called preprocessor directives which indicate that certain manipulations are to be performed on the program before compilation.

 Your test routine should do the following:

1)     Read in the input text from the input.dat into inputString character array.

2)     Find and print out the locations of all forms of “the” `s by calling EditFind function iteratively.

3)     Convert all “the” `s  to “THE” `s by calling EditFind and ChangeCase functions iteratively.  

4)     Find and cut the first occurrence of  “program”  by calling EditFind and EditCut functions in order.

5)     Paste the string cut in the previous string at the end of inputString by calling EditPaste function.

6)     Find and copy the first occurrence of “C program”  and replace it with the last occurrence of  “program”  by using EditFind, EditCopy and EditReplace functions.

Homework Assignment - 3  (Due to Dec 3rd) 

You are asked to write  a single main function containing answers  for each of the following questions. The order of statements in each function should correspond to the order of options  ( a) to g) or whatever) in the associated question (i.e., the first few statements in the function should be the answer for option a), second set of statements should be the answer for b), etc.)

You are allowed not to follow the Good Programming Practices related to naming variables this time because of the nature of the problem. However, you should clearly separate the answer for each answer by putting spaces to separate the logical sections of the code.

You also need to submit an output file containing the outputs of each question. This requires you to open a file called output#.dat where # is the number of corresponding exercise without a dot (e.g., 079, 103, etc.) and to direct (print out) all your messages into this file. 

Question 1) (Self-review exercise 10.3 of D&D, 2nd Edition ) Write a single statement or a set of statements to accomplish each of the following: …

Question 2) (Exercise 7.9 of D&D, 2nd Edition ) Answer each of the following. Assume that unsigned integers are stored in 2 bytes, and that the starting address of the array is at location 1002500 (decimal) in memory. …

Question 3) (Self-review exercise 8.1 of D&D, 2nd Edition ) Write a single statement to accomplish each of the following. Assume that variables c …

Question 4) (Exercise 6.9 of D&D, 2nd Edition ) Consider a 2-by-5 integer array t. …

P.S.1 You may form 2-person groups in doing this homework. 

P.S.2 See the homework policies for other instructions related to submitting your homework.

P.S.3 If you have 3rd Edition of the textbook, please find and answer the matching questions.

Homework Assignment - 2  (Due to Nov 5th)  ( Grading Policy)

Do the following exercises in the textbook: (2nd or 3rd edition)

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. 

Homework Assignment - 1  (Due to Oct 22nd)

Write a program  that reads in the names and the end of semester grades (one final, two midterms, and five homeworks) for five ELE-491 students, computes the average numeric score for each student, and prints out the names and scores of students in descending order. 

Homework Assignment - 0  (Due to Oct 22nd)

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.

Note 3: If you can scan your photo yourself, send your photo to me by e-mail.

Note 4: Turn in your homework in a plastic folder.

Name and last name:
Class: a) senior  b) master's
Student No:
E-mail address:
Personal Web page address: 
Have you ever attended English prep. shool during your education?
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: 
 

 

Send mail if any of your  grades (active version) is missing or wrong

Check out the Final Exam solutions

See TA's page for hot news!


Last updated: Aralύk 24, 2001 10:36:28 kdincer@ee.hacettepe.edu.tr