Please help me with this code becuase I dont think my output is correct. QUENEMAIN.CPP #include #include #include #include #include #include #include "LinkedQueue.h" using namespace std; /** * Name of input file containing officer names */ const char INPUT_FILE[] = "Alamo.csv"; /** * Inputs data from a text file and places each officer's name into the * queue passed as a parameter. * @param officers - dynamic queue of Confederate officers in the Civil War */ void loadQueue(LinkedQueue &officers); /** * Displays a list of officers removed from the queue and also displays * the name of the officer going for help. Retrieves officers from the * officers queue, one at a time, counting as each is retrieved. If the * count is not equal to hatNumber, the officer is put back into the * queue. When the count reaches hatNumber, that officer is removed from * the queue permanently (i.e., not put back into the queue), and the * officer's name is output to the screen. The last officer remaining in * the queue is the one shown as going for help. * @param officers - dynamic queue of Confederate officers in the Civil War * @param hatNumber - the number drawn from the hat, used to count off */ void countOff(LinkedQueue officers, int hatNumber); int main(void) { ifstream inFile(INPUT_FILE); // declare and open the input file int count; // number used for counting off LinkedQueue officers; // queue containing officer names string officerName; // name of officer in front of queue string firstName; // name of first officer in original queue loadQueue(officers); // Display list of officers in original queue cout << "_______________________________" << endl; cout << "OFFICERS IN THE ORIGINAL QUEUE: " << endl; cout << "-------------------------------" << endl; firstName = officers.peekFront(); cout << firstName << endl; officers.dequeue(); officers.enqueue(firstName); officerName = officers.peekFront(); while (firstName != officerName) { cout << officerName << endl; officers.dequeue(); officers.enqueue(officerName); officerName = officers.peekFront(); } // Test countOff() method using various numbers drawn from the hat count = 4; cout << endl << endl << "COUNT IS: " << count << endl; countOff(officers, count); // count = 8; // cout << endl << endl << "COUNT IS: " << count << endl; // countOff(officers, count); return EXIT_SUCCESS; } void loadQueue(LinkedQueue &officers) { ifstream inFile(INPUT_FILE); // declare and open the input file string officerName; // name of officer input from file if (!inFile) cout << "Error opening file for input: " << INPUT_FILE << endl; else { getline(inFile, officerName); //read https address getline(inFile, officerName); //read headers getline(inFile, officerName); //reads first name while (!inFile.eof()) { officers.enqueue(officerName); getline(inFile, officerName); } inFile.close(); } } void countOff(LinkedQueue officers, int count) { //write your code here }
Please help me with this code becuase I dont think my output is correct.
QUENEMAIN.CPP
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <stdexcept>
#include <cassert>
#include "LinkedQueue.h"
using namespace std;
/**
* Name of input file containing officer names
*/
const char INPUT_FILE[] = "Alamo.csv";
/**
* Inputs data from a text file and places each officer's name into the
* queue passed as a parameter.
* @param officers - dynamic queue of Confederate officers in the Civil War
*/
void loadQueue(LinkedQueue<string> &officers);
/**
* Displays a list of officers removed from the queue and also displays
* the name of the officer going for help. Retrieves officers from the
* officers queue, one at a time, counting as each is retrieved. If the
* count is not equal to hatNumber, the officer is put back into the
* queue. When the count reaches hatNumber, that officer is removed from
* the queue permanently (i.e., not put back into the queue), and the
* officer's name is output to the screen. The last officer remaining in
* the queue is the one shown as going for help.
* @param officers - dynamic queue of Confederate officers in the Civil War
* @param hatNumber - the number drawn from the hat, used to count off
*/
void countOff(LinkedQueue<string> officers, int hatNumber);
int main(void) {
ifstream inFile(INPUT_FILE); // declare and open the input file
int count; // number used for counting off
LinkedQueue<string> officers; // queue containing officer names
string officerName; // name of officer in front of queue
string firstName; // name of first officer in original queue
loadQueue(officers);
// Display list of officers in original queue
cout << "_______________________________" << endl;
cout << "OFFICERS IN THE ORIGINAL QUEUE: " << endl;
cout << "-------------------------------" << endl;
firstName = officers.peekFront();
cout << firstName << endl;
officers.dequeue();
officers.enqueue(firstName);
officerName = officers.peekFront();
while (firstName != officerName) {
cout << officerName << endl;
officers.dequeue();
officers.enqueue(officerName);
officerName = officers.peekFront();
}
// Test countOff() method using various numbers drawn from the hat
count = 4;
cout << endl << endl << "COUNT IS: " << count << endl;
countOff(officers, count);
// count = 8;
// cout << endl << endl << "COUNT IS: " << count << endl;
// countOff(officers, count);
return EXIT_SUCCESS;
}
void loadQueue(LinkedQueue<string> &officers) {
ifstream inFile(INPUT_FILE); // declare and open the input file
string officerName; // name of officer input from file
if (!inFile)
cout << "Error opening file for input: " << INPUT_FILE << endl;
else {
getline(inFile, officerName); //read https address
getline(inFile, officerName); //read headers
getline(inFile, officerName); //reads first name
while (!inFile.eof()) {
officers.enqueue(officerName);
getline(inFile, officerName);
}
inFile.close();
}
}
void countOff(LinkedQueue<string> officers, int count)
{
//write your code here
}
![During the Battle at the Alama a the defenders suddowdicovered thcy ore surrounded by an overwhelming force.
There is absolutely iso hope for victory without renforcements nd David Ciockett's horse is the only horse available
thut Can be used to escape and smon help. The defenders are toact to detemmine which of them is to go for
hielp
The defenders forma queue and thev pick a nunbor ficmahil. Beghning with the frst officer in the queue, they begin
to count, As each defender counts of, he moves to the ondiof the quoue When the count reaches the number that was
picked, that defender is nemoved froni the ueue, and the icount besagaln with De ot nan Once an defender is
removed trom the queue, he is no longer couned The list defender tha s i the quieue is the one that ddes
away on the horse to sumon help
For example, let's suppose the following defenders are stoeeid in the oubutt
Jan Abamilo SGT, Texas, fatality
James L Alen PVT, Kentucky. survivor
Robert Alen. PVT, Virgria fatltv
Horace Alsbury. PVT, Kentucky, sunvor
George Andrews atalty
Miles Deforest Andross PVT Vermont, fatalty
Jose Maris Arocha urvivor
Simon Arreola.
survivor
Micaah Autry. PVT, North Carblina faty
Jessie B. Badgett Tes sunivor
JuanA Badilio, SGT, Te tatality
Peter Janes Baliey
sac G Baker.PVT. Aikatsa litalty
Willa Chares M Baker CPT.Msoun fatity
John laad
PVT Kentucky Yataity
John lentine PVT. Pernsytvaria faality
Richard W Bllertine PVT, Scotird, fatalty
Lets alvo uppiose the rumber oicked fsh the hat is 4 S6d
the queue
counting off and inong to the back of
Attilo 2Aen Alen
Next is AsburyY d he is4.Since that is the numberd teom the h he
Pdhe will no be the defonder that goes belp
SWNtle. he b eot pt back into the
Now. wt bnounting gain
HA 2Ad 2-Arocha
sobe abo wals way. We bn countirg agan
1-Autri
2:0adgett 3-Ba
Elley is 4 so
Gker PVT Akans fatalty
wia Chines M Baket CPT.Mioul.fataley
Johini
John
Richard W. Bilertin PVT Scotand, fatalty
waks aay The ueue cunesdy lookse this
PVt Pesvar tae
te Sat Testatty
LAles PVC Kentuck
suniver
fatality
Robert Alen,PVT
George
Miks DeFort dros. Pt Veno fatalty
Jose Mar
Man Aury NT, North Cin lay
Jesse B Badee
taty
SGT Teas fatality
The process
UNS Way unt only one defender remains in the queue. The last defender remaining in the](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fdad58c83-f2ea-4146-b813-eac661fb8c00%2F2c5622eb-9345-497b-83db-a8356464ee27%2Flprmp8a_processed.jpeg&w=3840&q=75)
![The countOff() method displays the name of each officer removed from the queue, in the order in which they are
removed, and displays the name of the officer that goes for help. For example, the output for the queue of defenders
above with a count of 4 would appear as:
Defenders leaving the queue are:
Horace Alsbury, PVT, Kentucky, survivor
Simon Arreola, – survivor
Peter James Bailey III, PVT. Kentucky, fatality
John J. Ballentine, PVT, Pennsylvania, fatality
Robert Allen: PVT, Virginia, fatality
Micajah Autry, PVT, North Carolina, fatality
William Charles M. Baker, CPT, Missouri, fatality
James LAllen, PVT, Kentucky, survivor
Jesse B. Badgett
Richard W. Ballentine, PVT, Scotland, fatality
Texas, survivor
José María Arocha:
survivor
Juan Abamillo, SGT, Texas, fatality
Isaac G. Baker, PVT, Arkansas, fatality
Juan A. Badillo, SGT, Texas, fatality
John Ballard, -
,fatality
Miles DeForest Andross, PVT, Vermont, fatality
The defender going for help is: Gebrge Andrews, fatality
The countOff) method cannot create a data structure; it MUST use the LinkedQueue data structure named officers,
which is passed as an argument. QueueMain.cpp contains maint) function that you can choose to use, or you can write
your own, The downloaded folder also contains main.cpp which was used to test the functions in the LinkedQueue class
if you want to take a look at it.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fdad58c83-f2ea-4146-b813-eac661fb8c00%2F2c5622eb-9345-497b-83db-a8356464ee27%2Fjdtza9s_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)