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

  1. ๐Ÿ‘ 0
  2. ๐Ÿ‘Ž 0
  3. ๐Ÿ‘ 65
asked by Andre
  1. 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.

    1. ๐Ÿ‘ 0
    2. ๐Ÿ‘Ž 0
    posted by Steve
  2. 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.

    1. ๐Ÿ‘ 0
    2. ๐Ÿ‘Ž 0
    posted by Graham

Respond to this Question

First Name

Your Response

Similar Questions

  1. Math

    A high school senior vacationing in Jamaica for her senior class trip jumped off a 20 foot cliff into a pool of water. The height of the senior above the water is modeled by the function h(t)=-t^2+t/4+5/4 where h(t) is the height

    asked by Anonymous on February 13, 2014
  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.

    asked by Tina on April 29, 2012
  3. Algebra

    At Central High School, the sophomore class has 60 more students than the freshman class. The junior class has 50 fewer than twice the number of students in the freshman class. The senior class is three times as large as the

    asked by Anonymous on April 27, 2015
  4. Earth & Space Science

    Could someone please tell me what do you do in this class. I'm going to be a senior next year [High School] , & thinking of taking this class. And also if someone could tell me where to find notes for that class. THANK YOU!

    asked by DAN on May 2, 2012
  5. Math 140

    To help pay for a class trip at the end of the senior year, the junior class at a high school invests $1800 from a fund-raiser in a 18-month CD paying 2.6% interest compound monthly. Determine the amount the class will receive

    asked by Pamela on July 19, 2013
  6. SAT Math

    All of the students who took chemistry at Groveton High School last year were juniors or seniors, as shown in the table below. If 80% of the students who took chemistry passed, then what fraction of the students in the combined

    asked by Kay on December 27, 2016
  7. math

    รขโ‚ฌยขYou and three (3) of your friends were in the same advance placement high school chemistry class in high school. All four (4) of you decided to take the same chemistry class together at the local university along with 21

    asked by jacque on December 4, 2012
  8. Algebra

    There are 357 seniors in Harris High School. The ratio of boys to girls is 7:10. How many boys are in the senior class?

    asked by in need of help on March 10, 2010
  9. strayer

    You and three (3) of your friends were in the same advance placement high school chemistry class in high school. All four (4) of you decided to take the same chemistry class together at the local university along with 21 other

    asked by meka on February 28, 2012
  10. 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.

    asked by Jacob on September 23, 2011

More Similar Questions