Pascal help!

xxofnirxx

Beta member
Messages
1
Hi everybody. I have here a problem that is kicking my butt. I have no idea where to start on it. Here it is:

The company you are working for has just taken over a smaller company. The accounting department would like to have a combined list of employee id numbers and department codes for the two groups. They want the list in ascending order by id number. Your job is to write a program that will print stuch a list.

The employee id numbers (integer) and the single charachter department codes (char) for the smaller company are in ascending order already.

You do now know how many employees there are in the file, but you do know the max number of employeses they have had is 150. There is an id number of all zeroes to mark the end of the smaller compay's employees. the employee id numbers and department codes for the larger company follow this in the same file are are in ascending order also. There is no upper limit on the number of employees in this second group.

Output:
An ordered list of employeed id numbers and department codes followed by a 1 if from the smaller company and a 2 if from the larger company. The two lists are alreayd sorted, so all I have to do is merge them.



I'm really really lost. I have no idea where to even being. All of my programs have gone very smoothly until this one. Any help would be greatly appreciated. Thanks!
 
lucky for you i done this sometime this week in SDD class. :)

Basic pseudo code to help you write the program :) enjoy

______________________________________________________
BEGIN SUBPROGRAM Sorting

DECLARE StudRec
employee_id as integer
single_character_department_code as string
END DECLARE

DECLARE StudArray(1 to 150) as StudRec

OPEN list.txt for input
Index = 0

WHILE NOT EOF(list.txt) AND index < 150
Add 1 to index
READ StudArray(index).employee_id, StudArray(index).single_character_department_code from list.txt
ENDWHILE

CLOSE list.txt

NumOfEmployees = index
Unsorted = index - 1

FOR index = 1 to NumofEmployees - 1
FOR j = 1 to unsorted
IF StudArray(j).employee_id > StudArray(J + 1).employee_id THEN
tempEmployee = StudArray(j).employee_id
tempSingle = StudArray(j).single_character_department_code
StudArray(j).employee_id = StudArray (j + 1).employee_id
StudArray(j).single_character_department_code = StudArray(j + 1).single_character_department_code
StudArray(j + 1).employee_id = tempEmployee
StudArray(j + 1).single_character_department_code= tempSingle
ENDIF

NEXT
unsorted = unsorted - 1
NEXT
OPEN list

FOR index = 1 to NumOfEmployees
WRITE StudArray(index).employee_id, StudArray(index).single_character_department_code to list.txt
NEXT

CLOSE list.txt
END SUBPROGRAM Sorting
____________________________________________________________
 
Back
Top Bottom