Module 6 Com 204.docx - Module 6 Chapter 7 Exercises 3 Laramie Park District has files of participants in its summer and winter programs this year Each

# Module 6 Com 204.docx - Module 6 Chapter 7 Exercises 3...

• 15
• 92% (12) 11 out of 12 people found this document helpful

This preview shows page 1 - 5 out of 15 pages.

Module 6 Feb 17, 2018Chapter 7Exercises 3. Laramie Park District has files of participants in its summer and winter programs this year. Each file is in participant ID number order and contains additional fields for first name, last name, age, and class taken (for example,Beginning Swimming).A.Design the logic for a program that merges the files for summer and winter programs to create a list of the first and last names of all participants for the year in ID number order.startDeclarationInputFile win_CusInputFile sum_CusOutputFile mergefilenum win_Cus_Idnum id = 0String win_First_NameString win_Last_Namestring win_Classnum win_Age num sum_Cus_IdString sum_First_NameString sum_Last_Namestring sum_classnum sum_Agenum end_Num=9999String areBothAtEnd=”N”getReady()While arebothAtEnd=”Y”mergeRecord()endwhilefinishUp()stopgetReady()open win_Cus “win_cus.dat”open sum_Cus “sum_cus.dat”open mergefile “cus.dat”
readWin()readSum()checkEnd()returnreadWin()input win_Cus_Id, win_First_Name, win_Last_Namewin age, win_Classfrom win_Cus from win_CusIf eof then win_Cus_Id – end_Numendif return readSum()input sum_Cus_Id, sum_First_Name, sum_Last_Name,sum_Age, sum_Class from sum_CusIf eof thensum_Cus_Id = end_Numendifreturn checkEnd()if win_Cus_Id = end_Num andif sum_Cus_Id = end_Num thenareBothAtEnd = “Y”endifendifreturnmergerRecord()if win_Cus_Id < sum_Cus_Id thenoutput win_Cus_Id, win_First_Name,sum_Last_Name tomerge filereadSum()endifchseckEnd()returnfinish()close win_Cusclose sum_Cusclose mergefilereturnB.Modify the program so that if a participant has more than one record, the participant’s ID number and name are output only once.startDeclarationInputFile win_Cus
InputFile sum_CusOutputFile mergefilenum win_Cus_Idnum id = 0String win_First_NameString win_Last_Namestring win_Classnum win_Age num sum_Cus_IdString sum_First_NameString sum_Last_Namestring sum_classnum sum_Agenum end_Num=9999String areBothAtEnd=”N”getReady()While arebothAtEnd=”Y”mergeRecord()endwhilefinishUp()stopgetReady()open win_Cus “win_cus.dat”open sum_Cus “sum_cus.dat”open mergefile “cus.dat”readWin()readSum()checkEnd()returnreadWin()input win_Cus_Id, win_First_Name, win_Last_Name,win_Agewin_Cus_Id = end_NumendifreturnreadSum()input sum_Cus_Id, sum_First_Name, sum_Last_Namesum_Age,sum_Classif eof then sum_Cus_Id = end_NumendifreturncheckEnd()if win_Cus_Id = end_Num and
if sum_Cus_Id = end_Num thenareBothatend = “Y”endifendifreturnmergeRecord()if win_Cus_Id < sum_Cus_Id thenif win_Cus_Id <> Id then output sum_Cus_Id. sum_First_name,sum_Last_Name to merge fileid = sum_IdendifreadWin()elseif sum_Cus_Id <>id thenoutput win_Cus_id, win_First_Name,