programming

posted by .

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 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

  • programming -

    gee, how about entering your code in an IDE and

    (a) fix any syntax errors
    (b) step through the execution if your output is wrong.

  • programming -

    checkBoth() has a glaring logic error.

    detailLoop() need to consider what happens if you come to the end of one file before its room?Name is greater than that of the other. Avoiding an infinite loop would be a good idea.

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. 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 …
  2. Programming Logic

    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 …
  3. Geometry

    A special lottery is to be held to select the student who will live in the only deluxe room in a dormitory. There are 100 seniors, 150 juniors, and 200 sophomores who applied. Each senior's name is placed in the lottery 3 times; each …
  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. 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
  6. C++programming

    Write an interactive C program that will accept each student’s name an exam grades as input, determine an average grade for each student, and then display the student’s name, the individual exam grades and the calculated average. …
  7. 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 …
  8. 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 …
  9. 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?
  10. help algebra??

    stillwater junior high divides students into teams taught by a group of teachers the table shows the number of students in each team. imgur . com/x7kghII (picture of student numbers) The principle uses a computer to randomly select …

More Similar Questions