Programming Logic

posted by .

Find bugs.

// The two senior class homerooms at Littleville High School
// are having a fundraising drive for the prom. Each time a student
// solicits a contribution, a record is created with the
// student's name and the value. Two files have been created for Homeroom A and Homeroom B. 
// Each file is sorted in contribution value order from highest to lowest.
// This program merges the two files.
start
   // Declarations
      string roomAName
      num roomAValue
      string roomBName
      num roomBValue

      string bothFilesDone = "N"
      string HIGHVALUE = "XXXXX"
      InputFile roomAFile
      InputFile roomBFile
      OutputFile mergedFile
   getReady()
   while bothFilesDone = "N"
      detailLoop()
   endwhile
   allDone()
stop

getReady()  
   open roomAFile "roomAFile.dat"
   open roomBFile "roomBFile.dat"
   open mergedFile "mergedFile.dat"
   readA()
   readA()
   checkBoth()
return

readA()
   input roomAName, roomAValue from roomAFile
   if eof then
      roomAValue = HIGHVALUE
   endif
return

readB()
   input roomBName, roomBValue from roomBFile
   if eof then
      roomBValue = roomAValue
   endif
return

checkBoth()
   if roomAValue = HIGHVALUE AND roomAValue = HIGHVALUE then
      bothFilesDone = "Y"
   endif
return

detailLoop()
   if roomAName > roomBName then
      output roomBName, roomBValue to mergedFile
      readB()
   else
      output roomAName, roomAValue to mergedFile
      readA()
   endif
   checkBoth()
return
 
allDone()
   close roomAFile
   close roomBFile
   close mergedFile
return 

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. english

    how about this for starters? The shift from being a high school student to a college student can be both pleasurable and discomforting at the same time for the simple fact that college is nothing like high school. In college there
  2. Math

    There are one thousdand students in Central High School. Three hundred twenty-eight of the students are seniors. Write the decimal that shows what part of the student body is in the senior class.
  3. programming logic

    The program will accept user input to store the student's first and last name . If the name is ZZZ, then the program will end. The program will accept: a text entry for the class number (e.g., CGS 1000, COP 1000, etc.) a numeric value …
  4. IPC

    A student is running through the halls of solon high school at a constant velocity of 4 m/s, so that he/she can be on time to science class. If the class is 25 meters away, will the student make it in 5 seconds?
  5. programming logic raptor

    1. a.input names of students from the user, terminated by "zzz", 0,0,0, and create a data file grades with records of the following form: student (string), test1 (integer), test2(integer), test3 (integer) b. display the contents of …
  6. programming

    DEBUGGING // The two senior class homerooms at Littleville High School // are having a fundraising drive for the prom. Each time a student // solicits a contribution, a record is created with the // student's name and the value. Two …
  7. Algebra

    Help? The school john goes to is selling tickets to the annual dance competition . On the first day of sales the school sold 2 senior citizen tickets and 13 student tickets for a total of $108. The school took in$144 on the second
  8. Math(Algebra)

    de Sean it in school is selling tickets to a choral performance. on the first day of ticket selling the school sold eight senior citizen tickets and 12 students tickets for a total of $160. The school took in 115 on the second day …
  9. Programming C++ using Data Structure.

    In an academic institution, Student has its records. Each student has his/her profile such as id number, student name. The institution also keeps records of student grades in each subject. Student grades contains information subject …
  10. English

    There are 7 classes for first year students. Each class is composed of about 30 students. Emily is a student of Class 1-2. One of his classmates who went to the same elementary school asks: Which class are you in?

More Similar Questions