Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 04-28-2009, 10:20 AM   #1
Beta Member
Join Date: Apr 2009
Posts: 1
Default Pascal help!

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.

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!

xxofnirxx is offline   Reply With Quote
Old 04-29-2009, 08:09 AM   #2
In Runtime
Daeva's Avatar
Join Date: Dec 2005
Posts: 407
Send a message via AIM to Daeva Send a message via MSN to Daeva Send a message via Yahoo to Daeva
Default Re: Pascal help!

Could you post some of the code you have done on this one?

**Official Self-proclaimed glorified excessive (insert additional adjectives here) post editor/modifier.
Edit = Best feature ever
Daeva is offline   Reply With Quote
Old 06-25-2009, 08:13 AM   #3
Baseband Member
Join Date: Jun 2009
Posts: 34
Default Re: Pascal help!

lucky for you i done this sometime this week in SDD class.

Basic pseudo code to help you write the program enjoy

__________________________________________________ ____

employee_id as integer
single_character_department_code as string

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

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

unsorted = unsorted - 1
OPEN list

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

CLOSE list.txt
__________________________________________________ __________
danny_2132 is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 05:20 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0