SlideShare uma empresa Scribd logo
1 de 9
Baixar para ler offline
Please teach me how to fix the errors and where should be modified. Thank you!
"Program generated too much output. Output restricted to 50000 characters. Check program for
any unterminated loops generating output."
LinkedList.cpp
LinkedList::LinkedList() {
head = new Node;
head->next = NULL;
length = 0;
}
void LinkedList::insertNode(Sales dataIn) {
/* Write your code here */
Node *newNode;
Node *pCur;
Node *pPre;
newNode = new Node;
newNode->data = dataIn;
pPre = head;
pCur = head->next;
while (pCur != NULL && pCur->data.getName() < dataIn.getName()) {
pPre = pCur;
pCur = pCur->next;
}
pPre->next = newNode;
newNode->next = pCur;
length++;
}
bool LinkedList::deleteNode(string target){
Node *pCur;
Node *pPre;
bool deleted = false;
pPre = head;
pCur = head->next;
while (pCur != NULL && pCur->data.getName() < target) {
pPre = pCur;
pCur = pCur->next;
}
if (pCur != NULL && pCur->data.getName() == target) {
pPre->next = pCur->next;
delete pCur;
deleted = true;
length--;
}
return deleted;
}
void LinkedList::displayList() const{
Node *pCur;
pCur = head->next;
while (pCur) {
cout << pCur->data;
pCur = pCur->next;
}
cout << endl;
}
void LinkedList::displayList(int year) const {
Node *pCur;
pCur = head->next;
int cnt = 0;
while (pCur) {
if (pCur->data.getYear() == year){
cout << pCur->data;
cnt++;
}
pCur = pCur->next;
}
if (cnt == 0){
cout << "N/A" << endl;
}
}
double LinkedList::average() const {
double total = 0.0;
double average;
Node *pCur;
pCur = head;
while (pCur != NULL) {
total += pCur->data.getAmount();
pCur = pCur->next;
}
average = total / static_cast(length);
return average;
}
bool LinkedList::searchList(string find, Sales &dataOut) const {
bool found = false;
Node *pCur;
pCur = head->next;
while (pCur != NULL && pCur->data.getName() < find) {
pCur = pCur->next;
}
if (pCur != NULL && pCur->data.getName() == find) {
dataOut = pCur->data;
found = true;
}
return found;
}
LinkedList::~LinkedList() {
Node *pCur;
Node *pNext;
pCur = head->next;
while(pCur != NULL) {
pNext = pCur->next;
delete pCur;
pCur = pNext;
}
delete head;
}
main.cpp
void buildList(const string &filename, LinkedList &list);
void deleteManager(LinkedList &list);
void searchManager(const LinkedList &list);
void displayManager(const LinkedList &list);
int main() {
string inputFileName;
LinkedList list;
cout << "Enter file name: ";
getline(cin, inputFileName);
buildList(inputFileName, list);
displayManager(list);
searchManager(list);
deleteManager(list);
displayManager(list);
return 0;
}
void buildList(const string &filename, LinkedList &list) {
ifstream inFile(filename);
cout <<"Reading data from "" << filename << ""n";
if(!inFile) {
cout << "Error opening the input file: ""<< filename << """ << endl;
exit(EXIT_FAILURE);
}
string id;
int year;
string name;
int amount;
string line;
while (getline(inFile, line) ) {
stringstream temp(line);
temp >> id >> year;
temp.ignore();
getline(temp, name, ';');
temp >> amount;
// create a Sales object and initialize it with data from file
Sales obj;
obj.setId(id);
obj.setYear(year);
obj.setName(name);
obj.setAmount(amount);
// call insert to insert this new Sales object into the sorted list
list.insertNode(obj);
}
inFile.close();
}
void deleteManager(LinkedList &list) {
string target = "";
cout << " Delete" << endl;
cout << "========" << endl;
while(target != "Q") {
cout << "Enter a name (or Q to stop deleting):" << endl;
getline(cin, target);
target[0] = toupper(target[0]);
if(target != "Q") {
if(list.deleteNode(target))
cout << target << " has been deleted!" << endl;
else
cout << target << " not found!" << endl;
}
}
cout << "___________________END DELETE SECTION_____" << endl;
}
void searchManager(const LinkedList &list) {
string target = "";
Sales obj;
cout << " Search" << endl;
cout << "========" << endl;
while (target != "Q") {
cout << "Enter a name (or Q to stop searching):" << endl;
getline(cin, target);
target[0] = toupper(target[0]);
if (target != "Q") {
if (list.searchList(target, obj))
obj.display();
else
cout << target << " not found!" << endl;
}
}
cout << "___________________END SEARCH SECTION _____" << endl;
}
void displayManager(const LinkedList &list) {
// Sub-functions of displayManager()
void showMenu(void);
string getOption(void);
void showHeader(string line);
string line = "==== ==================== =============n";
string option;
showMenu();
option = getOption();
while(option[0] != 'Q') {
switch (option[0]) {
case 'A':
showHeader(line);
list.displayList();
cout << line;
break;
case 'G':
cout << "Average (amount sold) $";
cout << setprecision(2) << fixed;
cout << list.average() << endl;
break;
case 'Y':
int year;
cout << "Enter year: " << endl;
cin >> year;
showHeader(line);
list.displayList(year);
cout << line;
break;
}
option = getOption();
}
cout << "Number of salespeople: " << list.getLength() << endl;
}
void showHeader(string line) {
cout << line;
cout << "Year" << " " << left << setw(20) << "Name"
<< " Amount Earned" << endl;
cout << line;
}
string getOption(void) {
string option;
cout << "What is your option [A/G/Y/Q]?" << endl;
cin >> option;
cin.ignore();
option[0] = toupper(option[0]);
while (option != "A" && option != "G" && option != "Y" && option != "Q") {
cout << "Invalid Option: Try again!";
cout << "What is your option [A/G/Y/Q]?" << endl;
cin >> option;
cin.ignore();
option[0] = toupper(option[0]);
}
return option;
}
void showMenu(void) {
cout << "The following reports are available: " << endl;
cout << "[A] - All" << endl
<< "[G] - Average" << endl
<< "[Y] - Year Hired" << endl
<< "[Q] - Quit" << endl;
}

Mais conteúdo relacionado

Semelhante a Please teach me how to fix the errors and where should be modified. .pdf

#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
 #ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf #ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdfangelsfashion1
 
program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)Ankit Gupta
 
C++ adt c++ implementations
C++   adt c++ implementationsC++   adt c++ implementations
C++ adt c++ implementationsRex Mwamba
 
#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdfharihelectronicspune
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdffantoosh1
 
In C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfIn C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfflashfashioncasualwe
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfaathiauto
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListQueue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListPTCL
 
#include iostream #include cstring #include vector #i.pdf
 #include iostream #include cstring #include vector #i.pdf #include iostream #include cstring #include vector #i.pdf
#include iostream #include cstring #include vector #i.pdfanandatalapatra
 
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfaassecuritysystem
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfalphaagenciesindia
 
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfincludestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfgalagirishp
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdffeelinggift
 
LISTINGS.txt345678 116900 0 80513-2918 Metro Brokers432395.docx
LISTINGS.txt345678 116900 0 80513-2918  Metro Brokers432395.docxLISTINGS.txt345678 116900 0 80513-2918  Metro Brokers432395.docx
LISTINGS.txt345678 116900 0 80513-2918 Metro Brokers432395.docxSHIVA101531
 

Semelhante a Please teach me how to fix the errors and where should be modified. .pdf (20)

#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
 #ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf #ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
#ifndef LINKED_LIST_ #define LINKED_LIST_ templateclass It.pdf
 
program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)program on string in java Lab file 2 (3-year)
program on string in java Lab file 2 (3-year)
 
C++ adt c++ implementations
C++   adt c++ implementationsC++   adt c++ implementations
C++ adt c++ implementations
 
Ds 2 cycle
Ds 2 cycleDs 2 cycle
Ds 2 cycle
 
#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf
 
dynamicList.ppt
dynamicList.pptdynamicList.ppt
dynamicList.ppt
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdf
 
In C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdfIn C++Write a recursive function to determine whether or not a Lin.pdf
In C++Write a recursive function to determine whether or not a Lin.pdf
 
Arrays
ArraysArrays
Arrays
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdfDoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
DoublyList-cpp- #include -DoublyList-h- using namespace std- void Doub.pdf
 
Opp compile
Opp compileOpp compile
Opp compile
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListQueue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked List
 
#include iostream #include cstring #include vector #i.pdf
 #include iostream #include cstring #include vector #i.pdf #include iostream #include cstring #include vector #i.pdf
#include iostream #include cstring #include vector #i.pdf
 
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdfC++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
C++ Language -- Dynamic Memory -- There are 7 files in this project- a.pdf
 
Rewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdfRewrite this code so it can use a generic type instead of integers. .pdf
Rewrite this code so it can use a generic type instead of integers. .pdf
 
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdfincludestdio.h #includestdlib.h int enqueue(struct node ,.pdf
includestdio.h #includestdlib.h int enqueue(struct node ,.pdf
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
 
LISTINGS.txt345678 116900 0 80513-2918 Metro Brokers432395.docx
LISTINGS.txt345678 116900 0 80513-2918  Metro Brokers432395.docxLISTINGS.txt345678 116900 0 80513-2918  Metro Brokers432395.docx
LISTINGS.txt345678 116900 0 80513-2918 Metro Brokers432395.docx
 

Mais de amarndsons

Plot the marginal utility of food. Remember to plot using midpoints#.pdf
Plot the marginal utility of food. Remember to plot using midpoints#.pdfPlot the marginal utility of food. Remember to plot using midpoints#.pdf
Plot the marginal utility of food. Remember to plot using midpoints#.pdfamarndsons
 
Please write the mysh program in C and follow the guidelines specifi.pdf
Please write the mysh program in C and follow the guidelines specifi.pdfPlease write the mysh program in C and follow the guidelines specifi.pdf
Please write the mysh program in C and follow the guidelines specifi.pdfamarndsons
 
Please write the program mysh in C programming language and follow.pdf
Please write the program mysh in C programming language and follow.pdfPlease write the program mysh in C programming language and follow.pdf
Please write the program mysh in C programming language and follow.pdfamarndsons
 
Please write the C++ code that would display the exact same output a.pdf
Please write the C++ code that would display the exact same output a.pdfPlease write the C++ code that would display the exact same output a.pdf
Please write the C++ code that would display the exact same output a.pdfamarndsons
 
please write in C programming Write in C code that is able to rea.pdf
please write in C programming  Write in C code that is able to rea.pdfplease write in C programming  Write in C code that is able to rea.pdf
please write in C programming Write in C code that is able to rea.pdfamarndsons
 
please will you answer the following questions about chromatin struc.pdf
please will you answer the following questions about chromatin struc.pdfplease will you answer the following questions about chromatin struc.pdf
please will you answer the following questions about chromatin struc.pdfamarndsons
 
Please write a detailed post responding to this question.Question.pdf
Please write a detailed post responding to this question.Question.pdfPlease write a detailed post responding to this question.Question.pdf
Please write a detailed post responding to this question.Question.pdfamarndsons
 
Please write a detailed assessment of the long-term advantages and d.pdf
Please write a detailed assessment of the long-term advantages and d.pdfPlease write a detailed assessment of the long-term advantages and d.pdf
Please write a detailed assessment of the long-term advantages and d.pdfamarndsons
 
PLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdf
PLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdfPLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdf
PLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdfamarndsons
 
Please use your own word and dont copy and paste the anwser from ke.pdf
Please use your own word and dont copy and paste the anwser from ke.pdfPlease use your own word and dont copy and paste the anwser from ke.pdf
Please use your own word and dont copy and paste the anwser from ke.pdfamarndsons
 
Please use one of the 2 Excel files (BirdSrtike or Super-SampleStore.pdf
Please use one of the 2 Excel files (BirdSrtike or Super-SampleStore.pdfPlease use one of the 2 Excel files (BirdSrtike or Super-SampleStore.pdf
Please use one of the 2 Excel files (BirdSrtike or Super-SampleStore.pdfamarndsons
 
Please state whether each of the following statements is True or Fal.pdf
Please state whether each of the following statements is True or Fal.pdfPlease state whether each of the following statements is True or Fal.pdf
Please state whether each of the following statements is True or Fal.pdfamarndsons
 
Please tell me why I get this error in my code I have the screen sh.pdf
Please tell me why I get this error in my code I have the screen sh.pdfPlease tell me why I get this error in my code I have the screen sh.pdf
Please tell me why I get this error in my code I have the screen sh.pdfamarndsons
 
please solve this problem using R language 3. The following data .pdf
please solve this problem using R language  3. The following data .pdfplease solve this problem using R language  3. The following data .pdf
please solve this problem using R language 3. The following data .pdfamarndsons
 
Please show all the necessary steps to find the above op code Q2. (1.pdf
Please show all the necessary steps to find the above op code Q2. (1.pdfPlease show all the necessary steps to find the above op code Q2. (1.pdf
Please show all the necessary steps to find the above op code Q2. (1.pdfamarndsons
 
Please show all steps i want to understand whats happening. 2- Solve.pdf
Please show all steps i want to understand whats happening. 2- Solve.pdfPlease show all steps i want to understand whats happening. 2- Solve.pdf
Please show all steps i want to understand whats happening. 2- Solve.pdfamarndsons
 
Please Show all work. 1. Show that the language L1={ann is prime } .pdf
Please Show all work. 1. Show that the language L1={ann is prime } .pdfPlease Show all work. 1. Show that the language L1={ann is prime } .pdf
Please Show all work. 1. Show that the language L1={ann is prime } .pdfamarndsons
 
please show your work (Remember You may find the standard normal ta.pdf
please show your work (Remember You may find the standard normal ta.pdfplease show your work (Remember You may find the standard normal ta.pdf
please show your work (Remember You may find the standard normal ta.pdfamarndsons
 
Please show the math for the stepsPart 1A.Part 1BPart 1C Us.pdf
Please show the math for the stepsPart 1A.Part 1BPart 1C Us.pdfPlease show the math for the stepsPart 1A.Part 1BPart 1C Us.pdf
Please show the math for the stepsPart 1A.Part 1BPart 1C Us.pdfamarndsons
 
Please show all work and explain the answer! which of the following .pdf
Please show all work and explain the answer! which of the following .pdfPlease show all work and explain the answer! which of the following .pdf
Please show all work and explain the answer! which of the following .pdfamarndsons
 

Mais de amarndsons (20)

Plot the marginal utility of food. Remember to plot using midpoints#.pdf
Plot the marginal utility of food. Remember to plot using midpoints#.pdfPlot the marginal utility of food. Remember to plot using midpoints#.pdf
Plot the marginal utility of food. Remember to plot using midpoints#.pdf
 
Please write the mysh program in C and follow the guidelines specifi.pdf
Please write the mysh program in C and follow the guidelines specifi.pdfPlease write the mysh program in C and follow the guidelines specifi.pdf
Please write the mysh program in C and follow the guidelines specifi.pdf
 
Please write the program mysh in C programming language and follow.pdf
Please write the program mysh in C programming language and follow.pdfPlease write the program mysh in C programming language and follow.pdf
Please write the program mysh in C programming language and follow.pdf
 
Please write the C++ code that would display the exact same output a.pdf
Please write the C++ code that would display the exact same output a.pdfPlease write the C++ code that would display the exact same output a.pdf
Please write the C++ code that would display the exact same output a.pdf
 
please write in C programming Write in C code that is able to rea.pdf
please write in C programming  Write in C code that is able to rea.pdfplease write in C programming  Write in C code that is able to rea.pdf
please write in C programming Write in C code that is able to rea.pdf
 
please will you answer the following questions about chromatin struc.pdf
please will you answer the following questions about chromatin struc.pdfplease will you answer the following questions about chromatin struc.pdf
please will you answer the following questions about chromatin struc.pdf
 
Please write a detailed post responding to this question.Question.pdf
Please write a detailed post responding to this question.Question.pdfPlease write a detailed post responding to this question.Question.pdf
Please write a detailed post responding to this question.Question.pdf
 
Please write a detailed assessment of the long-term advantages and d.pdf
Please write a detailed assessment of the long-term advantages and d.pdfPlease write a detailed assessment of the long-term advantages and d.pdf
Please write a detailed assessment of the long-term advantages and d.pdf
 
PLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdf
PLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdfPLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdf
PLEASE USE TuProlog for this. Also the facts need to be Binary Fac.pdf
 
Please use your own word and dont copy and paste the anwser from ke.pdf
Please use your own word and dont copy and paste the anwser from ke.pdfPlease use your own word and dont copy and paste the anwser from ke.pdf
Please use your own word and dont copy and paste the anwser from ke.pdf
 
Please use one of the 2 Excel files (BirdSrtike or Super-SampleStore.pdf
Please use one of the 2 Excel files (BirdSrtike or Super-SampleStore.pdfPlease use one of the 2 Excel files (BirdSrtike or Super-SampleStore.pdf
Please use one of the 2 Excel files (BirdSrtike or Super-SampleStore.pdf
 
Please state whether each of the following statements is True or Fal.pdf
Please state whether each of the following statements is True or Fal.pdfPlease state whether each of the following statements is True or Fal.pdf
Please state whether each of the following statements is True or Fal.pdf
 
Please tell me why I get this error in my code I have the screen sh.pdf
Please tell me why I get this error in my code I have the screen sh.pdfPlease tell me why I get this error in my code I have the screen sh.pdf
Please tell me why I get this error in my code I have the screen sh.pdf
 
please solve this problem using R language 3. The following data .pdf
please solve this problem using R language  3. The following data .pdfplease solve this problem using R language  3. The following data .pdf
please solve this problem using R language 3. The following data .pdf
 
Please show all the necessary steps to find the above op code Q2. (1.pdf
Please show all the necessary steps to find the above op code Q2. (1.pdfPlease show all the necessary steps to find the above op code Q2. (1.pdf
Please show all the necessary steps to find the above op code Q2. (1.pdf
 
Please show all steps i want to understand whats happening. 2- Solve.pdf
Please show all steps i want to understand whats happening. 2- Solve.pdfPlease show all steps i want to understand whats happening. 2- Solve.pdf
Please show all steps i want to understand whats happening. 2- Solve.pdf
 
Please Show all work. 1. Show that the language L1={ann is prime } .pdf
Please Show all work. 1. Show that the language L1={ann is prime } .pdfPlease Show all work. 1. Show that the language L1={ann is prime } .pdf
Please Show all work. 1. Show that the language L1={ann is prime } .pdf
 
please show your work (Remember You may find the standard normal ta.pdf
please show your work (Remember You may find the standard normal ta.pdfplease show your work (Remember You may find the standard normal ta.pdf
please show your work (Remember You may find the standard normal ta.pdf
 
Please show the math for the stepsPart 1A.Part 1BPart 1C Us.pdf
Please show the math for the stepsPart 1A.Part 1BPart 1C Us.pdfPlease show the math for the stepsPart 1A.Part 1BPart 1C Us.pdf
Please show the math for the stepsPart 1A.Part 1BPart 1C Us.pdf
 
Please show all work and explain the answer! which of the following .pdf
Please show all work and explain the answer! which of the following .pdfPlease show all work and explain the answer! which of the following .pdf
Please show all work and explain the answer! which of the following .pdf
 

Último

Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
The Emergence of Legislative Behavior in the Colombian Congress
The Emergence of Legislative Behavior in the Colombian CongressThe Emergence of Legislative Behavior in the Colombian Congress
The Emergence of Legislative Behavior in the Colombian CongressMaria Paula Aroca
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...Nguyen Thanh Tu Collection
 
physiotherapy in Acne condition.....pptx
physiotherapy in Acne condition.....pptxphysiotherapy in Acne condition.....pptx
physiotherapy in Acne condition.....pptxAneriPatwari
 
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEPART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEMISSRITIMABIOLOGYEXP
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroomSamsung Business USA
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationdeepaannamalai16
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Osopher
 
Unit :1 Basics of Professional Intelligence
Unit :1 Basics of Professional IntelligenceUnit :1 Basics of Professional Intelligence
Unit :1 Basics of Professional IntelligenceDr Vijay Vishwakarma
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxAnupam32727
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptxmary850239
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPCeline George
 
BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 8 - CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC ...
BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 8 - CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC ...BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 8 - CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC ...
BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 8 - CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC ...Nguyen Thanh Tu Collection
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptxmary850239
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6Vanessa Camilleri
 

Último (20)

Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
The Emergence of Legislative Behavior in the Colombian Congress
The Emergence of Legislative Behavior in the Colombian CongressThe Emergence of Legislative Behavior in the Colombian Congress
The Emergence of Legislative Behavior in the Colombian Congress
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - I-LEARN SMART WORLD - CẢ NĂM - CÓ FILE NGHE (BẢN...
 
Chi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical VariableChi-Square Test Non Parametric Test Categorical Variable
Chi-Square Test Non Parametric Test Categorical Variable
 
physiotherapy in Acne condition.....pptx
physiotherapy in Acne condition.....pptxphysiotherapy in Acne condition.....pptx
physiotherapy in Acne condition.....pptx
 
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFEPART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
PART 1 - CHAPTER 1 - CELL THE FUNDAMENTAL UNIT OF LIFE
 
6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom6 ways Samsung’s Interactive Display powered by Android changes the classroom
6 ways Samsung’s Interactive Display powered by Android changes the classroom
 
Congestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentationCongestive Cardiac Failure..presentation
Congestive Cardiac Failure..presentation
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
Healthy Minds, Flourishing Lives: A Philosophical Approach to Mental Health a...
 
Unit :1 Basics of Professional Intelligence
Unit :1 Basics of Professional IntelligenceUnit :1 Basics of Professional Intelligence
Unit :1 Basics of Professional Intelligence
 
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptxCLASSIFICATION OF ANTI - CANCER DRUGS.pptx
CLASSIFICATION OF ANTI - CANCER DRUGS.pptx
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx4.11.24 Poverty and Inequality in America.pptx
4.11.24 Poverty and Inequality in America.pptx
 
An Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERPAn Overview of the Calendar App in Odoo 17 ERP
An Overview of the Calendar App in Odoo 17 ERP
 
BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 8 - CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC ...
BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 8 - CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC ...BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 8 - CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC ...
BÀI TẬP BỔ TRỢ 4 KĨ NĂNG TIẾNG ANH LỚP 8 - CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC ...
 
4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx4.9.24 Social Capital and Social Exclusion.pptx
4.9.24 Social Capital and Social Exclusion.pptx
 
ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6ICS 2208 Lecture Slide Notes for Topic 6
ICS 2208 Lecture Slide Notes for Topic 6
 

Please teach me how to fix the errors and where should be modified. .pdf

  • 1. Please teach me how to fix the errors and where should be modified. Thank you! "Program generated too much output. Output restricted to 50000 characters. Check program for any unterminated loops generating output." LinkedList.cpp LinkedList::LinkedList() { head = new Node; head->next = NULL; length = 0; } void LinkedList::insertNode(Sales dataIn) { /* Write your code here */ Node *newNode; Node *pCur; Node *pPre; newNode = new Node; newNode->data = dataIn; pPre = head; pCur = head->next; while (pCur != NULL && pCur->data.getName() < dataIn.getName()) { pPre = pCur; pCur = pCur->next; } pPre->next = newNode; newNode->next = pCur; length++; } bool LinkedList::deleteNode(string target){ Node *pCur;
  • 2. Node *pPre; bool deleted = false; pPre = head; pCur = head->next; while (pCur != NULL && pCur->data.getName() < target) { pPre = pCur; pCur = pCur->next; } if (pCur != NULL && pCur->data.getName() == target) { pPre->next = pCur->next; delete pCur; deleted = true; length--; } return deleted; } void LinkedList::displayList() const{ Node *pCur; pCur = head->next; while (pCur) { cout << pCur->data; pCur = pCur->next; } cout << endl; } void LinkedList::displayList(int year) const {
  • 3. Node *pCur; pCur = head->next; int cnt = 0; while (pCur) { if (pCur->data.getYear() == year){ cout << pCur->data; cnt++; } pCur = pCur->next; } if (cnt == 0){ cout << "N/A" << endl; } } double LinkedList::average() const { double total = 0.0; double average; Node *pCur; pCur = head; while (pCur != NULL) { total += pCur->data.getAmount(); pCur = pCur->next; } average = total / static_cast(length); return average; } bool LinkedList::searchList(string find, Sales &dataOut) const {
  • 4. bool found = false; Node *pCur; pCur = head->next; while (pCur != NULL && pCur->data.getName() < find) { pCur = pCur->next; } if (pCur != NULL && pCur->data.getName() == find) { dataOut = pCur->data; found = true; } return found; } LinkedList::~LinkedList() { Node *pCur; Node *pNext; pCur = head->next; while(pCur != NULL) { pNext = pCur->next; delete pCur; pCur = pNext; } delete head; } main.cpp void buildList(const string &filename, LinkedList &list); void deleteManager(LinkedList &list); void searchManager(const LinkedList &list); void displayManager(const LinkedList &list); int main() { string inputFileName;
  • 5. LinkedList list; cout << "Enter file name: "; getline(cin, inputFileName); buildList(inputFileName, list); displayManager(list); searchManager(list); deleteManager(list); displayManager(list); return 0; } void buildList(const string &filename, LinkedList &list) { ifstream inFile(filename); cout <<"Reading data from "" << filename << ""n"; if(!inFile) { cout << "Error opening the input file: ""<< filename << """ << endl; exit(EXIT_FAILURE); } string id; int year; string name; int amount; string line; while (getline(inFile, line) ) { stringstream temp(line); temp >> id >> year; temp.ignore(); getline(temp, name, ';'); temp >> amount; // create a Sales object and initialize it with data from file Sales obj; obj.setId(id);
  • 6. obj.setYear(year); obj.setName(name); obj.setAmount(amount); // call insert to insert this new Sales object into the sorted list list.insertNode(obj); } inFile.close(); } void deleteManager(LinkedList &list) { string target = ""; cout << " Delete" << endl; cout << "========" << endl; while(target != "Q") { cout << "Enter a name (or Q to stop deleting):" << endl; getline(cin, target); target[0] = toupper(target[0]); if(target != "Q") { if(list.deleteNode(target)) cout << target << " has been deleted!" << endl; else cout << target << " not found!" << endl; } } cout << "___________________END DELETE SECTION_____" << endl; } void searchManager(const LinkedList &list) { string target = ""; Sales obj; cout << " Search" << endl; cout << "========" << endl;
  • 7. while (target != "Q") { cout << "Enter a name (or Q to stop searching):" << endl; getline(cin, target); target[0] = toupper(target[0]); if (target != "Q") { if (list.searchList(target, obj)) obj.display(); else cout << target << " not found!" << endl; } } cout << "___________________END SEARCH SECTION _____" << endl; } void displayManager(const LinkedList &list) { // Sub-functions of displayManager() void showMenu(void); string getOption(void); void showHeader(string line); string line = "==== ==================== =============n"; string option; showMenu(); option = getOption(); while(option[0] != 'Q') { switch (option[0]) { case 'A': showHeader(line); list.displayList(); cout << line; break; case 'G': cout << "Average (amount sold) $";
  • 8. cout << setprecision(2) << fixed; cout << list.average() << endl; break; case 'Y': int year; cout << "Enter year: " << endl; cin >> year; showHeader(line); list.displayList(year); cout << line; break; } option = getOption(); } cout << "Number of salespeople: " << list.getLength() << endl; } void showHeader(string line) { cout << line; cout << "Year" << " " << left << setw(20) << "Name" << " Amount Earned" << endl; cout << line; } string getOption(void) { string option; cout << "What is your option [A/G/Y/Q]?" << endl; cin >> option; cin.ignore(); option[0] = toupper(option[0]); while (option != "A" && option != "G" && option != "Y" && option != "Q") { cout << "Invalid Option: Try again!"; cout << "What is your option [A/G/Y/Q]?" << endl; cin >> option; cin.ignore();
  • 9. option[0] = toupper(option[0]); } return option; } void showMenu(void) { cout << "The following reports are available: " << endl; cout << "[A] - All" << endl << "[G] - Average" << endl << "[Y] - Year Hired" << endl << "[Q] - Quit" << endl; }