Please I need help debugging this code thanks.
// 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"
num HIGH_VALUE = 999999
InputFile roomAFile
InputFile roomBFile
InputFile mergedFile
getReady()
while bothFilesDone = "N"
detailLoop()
endwhile
allDone()
stop
getReady()
open roomAFile "roomAFile.dat"
open roomBFile "roomBFile.dat"
open mergedFile "mergedFile.dat"
readA()
readB()
checkBoth()
return
readA()
input roomAName, roomAValue from roomAFile
if eof then
roomAValue = HIGH_VALUE
endif
return
readB()
input roomBName, roomBValue from roomBFile
if eof then
roomBValue = HIGH_VALUE
endif
return
checkBoth()
if roomAValue = HIGH_VALUE AND roomBValue = HIGH_VALUE
then
bothFilesDone = "Y"
endif
return
detailLoop()
if roomAValue > roomBValue then
output roomBName, roomBValue to
mergedFile
readA()
else
output roomAName, roomAValue to
mergedFile
readB()
endif
return
allDone()
close roomAFile
close roomBFile
close mergeFile
return
IF YOU HAVE ANY DOUBTS PLEASE COMMENT BELOW I WILL THERE TO HELP YOU
PLEASE MAKE THUMBSUP
ANSWER:
CODE:
start
Declarations
string roomAName
num roomAValue
string roomBName
num roomBValue
string bothFilesDone = "N"
num HIGH_VALUE = 999999
InputFile roomAFile
InputFile roomBFile
InputFile mergedFile
getReady()
while bothFilesDone = "N"
detailLoop()
endwhile
allDone()
stop
getReady()
open roomAFile "roomAFile.dat"
open roomBFile "roomBFile.dat"
open mergedFile "mergedFile.dat"
readA()
readB()
checkBoth()
return
readA()
input roomAName, roomAValue from roomAFile
if eof then
roomAValue = HIGH_VALUE
endif
return
readB()
input roomBName, roomBValue from roomBFile
if eof then
roomBValue = HIGH_VALUE
endif
return
checkBoth()
if roomAValue = HIGH_VALUE AND roomBValue = HIGH_VALUE then
bothFilesDone = "Y"
endif
return
detailLoop()
if roomAValue > roomBValue then
output roomBName, roomBValue to mergedFile /* It should be output roomAName, roomAValue to mergedFile */
readA()
else
output roomAName, roomAValue to mergedFile /* it should be output roomBName, roomBValue to mergedFile */
readB()
endif
/* Here checkBoth() method should be called */
return
allDone()
close roomAFile
close roomBFile
close mergeFile
return
Explanation:
1. The 2nd line in detailLoop() method should be output roomAName, roomAValue from roomAFilebecause the introductory comment of debbuging 2 states that Each file is sorted in contribution value order from highest to lowest. in if (roomAValue> roomBValue) is true means roomAFile values should be copied to mergerFile.
2. The 5th line in detailsLoop() method should be output roomBName, roomBValue from roomBFilebeacuse as stated above if if condition is false then roomBFile values should be copied to mergeFile.
3. After endif in detailLoop() function there should be checkBoth() function because it will check for the both files are at EOF or not. If it is true then the "Y" is assigned to bothFileDone variable and then while(bothFileDone="N") will be failed so that we can exit from the loop. otherwise it will turn to infinite loop.
RATE THUMBSUP
THANKS
Please I need help debugging this code thanks. // The two senior class homerooms at Littleville...
I need help debugging this C++ prgram. What Am i doing wrong? //******************************************************** // This program reads two input files whose lines are //ordered by a key data field. This program should merge //these two files, writing an output file that contains //all lines from both files ordered by the same key field. // //********************************************************* #include <iostream> #include<string> #include<fstream> //prototype void mergeTwoFiles (ifstream&,ifstream&, ofstream&); using namespace std; int main() {string inFile1,inFile2,outFile; // input and output files ifstream in1; ifstream in2;...
Turning this Pseudocode into the described C++ Program? (will include Pseudocode AND Description of the Program below!) Pseudoode: start Declarations num deptNum num salary num hrsWorked num SIZE = 7 num totalGross[SIZE] = 0 string DEPTS[SIZE] = “Personnel”, “Marketing”, “Manufacturing”, “Computer Services”, “Sales”, “Accounting”, “Shipping” getReady() while not eof detailLoop() endwhile finishUp() stop getReady() output “Enter the department number, hourly salary, and number of hours worked” input deptNum, salary, hrsWorked return detailLoop() if deptNum >= 1 AND deptNum...
The following files starts with some comments that describe
the problem comments are lines that begin with two slashes(//).
following the comments the file contains pseudocode that has one or
more bugs you must find and correct
Class Class 12. Debug (5 points) The following file starts with some comments that describe the prolblemcnpseudocode lines that begin with two slashes Un). Following the comments, the file that has one or more bugs you must find and correct. This Eile defines...
C++ requirements The store number must be of type unsigned int. The sales value must be of of type long long int. Your program must properly check for end of file. See the section Reading in files below and also see your Gaddis text book for details on reading in file and checking for end of file. Your program must properly open and close all files. Failure to follow the C++ requirements could reduce the points received from passing the...
Please use my Lab 3.2 code for this assignment Lab 4.2 instruction Using the code from lab 4.1, add the ability to read from a file. Modify the input function: * Move the input function out of the Cargo class to just below the end of the Cargo class * At the bottom of the input function, declare a Cargo object named temp using the constructor that takes the six parameters. * Use the Cargo output...
CODE ERROR Please help to fix the error. I don't know why I can not output to file. when I open the output file there is an error. here is the input data: Princeton University NJ Princeton 41820 8014 0.0740 0.98 0.97 Harvard University MA Cambridge 43838 19882 0.0580 0.97 0.97 Yale University CT New Haven 45800 12109 0.0690 0.99 0.98 Columbia University NY New York 51008 23606 0.0690 0.99 0.96 Stanford University CA...
I need help with this problem. Using Python please. Thanks Construct a class “Monster” with the following attributes: self.name (a string) self.type (a string, default is ‘Normal’) self.current_hp (int, starts out equal to max_hp) self.max_hp (int, is given as input when the class instance is created, default is 20) self.exp (int, starts at 0, is increased by fighting) self.attacks (a dict of all known attacks) self.possible_attacks (a dictionary of all possible attacks The dictionary of possible_attacks will map the name...
I need help with this code,
I'm stuck on it, please remember step 4, I'm very much stuck on
that part. It says something about putting how many times it
appears
Assignment #1: Sorting with Binary Search Tree Through this programming assignment, the students will learn to do the following: Know how to process command line arguments. 1 Perform basic file I/O. 2. Use structs, pointers, and strings. Use dynamic memory. 3. 4. This assignment asks you to sort the...
Please help fix my code C++, I get 2 errors when running. The code should be able to open this file: labdata.txt Pallet PAG PAG45982IB 737 4978 OAK Container AYF AYF23409AA 737 2209 LAS Container AAA AAA89023DL 737 5932 DFW Here is my code: #include <iostream> #include <string> #include <fstream> #include <vector> #include <cstdlib> #include <iomanip> using namespace std; const int MAXLOAD737 = 46000; const int MAXLOAD767 = 116000; class Cargo { protected: string uldtype; string abbreviation; string uldid; int...
Need help with this class and function please!!!
#include <iostream>
using namespace std;
class Team {
string teamId;
string name;
string coach;
Team *next;
friend class teamlist;
public:
Team * getNext();
return next;
void setNext(Team *r);
next=r;
string getTeamId();
return teamId;
void setTeamId(string aTeamId);
teamId = aTeamId;
string getName();
return name;
void setName(string aName);
name = aName;
string getCoach();
return coach;
void setCoach(string aCoach);
coach = aCoach;
}
team list The team list is a dynamic linked list of team...