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 }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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
Transcribed Image Text: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
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.
Transcribed Image Text: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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY