SlideShare a Scribd company logo
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;
}

More Related Content

Similar to 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.pdf
angelsfashion1
 
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++ implementations
Rex Mwamba
 
Ds 2 cycle
Ds 2 cycleDs 2 cycle
Ds 2 cycle
Chaitanya Kn
 
#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf#includeiostream #includecstdio #includecstdlib using na.pdf
#includeiostream #includecstdio #includecstdlib using na.pdf
harihelectronicspune
 
dynamicList.ppt
dynamicList.pptdynamicList.ppt
dynamicList.ppt
ssuser0be977
 
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
fantoosh1
 
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
flashfashioncasualwe
 
Arrays
ArraysArrays
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
Lakshmi Sarvani Videla
 
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
aathiauto
 
Opp compile
Opp compileOpp compile
Opp compile
Muhammad Faiz
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked ListQueue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked List
PTCL
 
#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
anandatalapatra
 
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
aassecuritysystem
 
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
alphaagenciesindia
 
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
galagirishp
 
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
feelinggift
 
DS Code (CWH).docx
DS Code (CWH).docxDS Code (CWH).docx
DS Code (CWH).docx
KamalSaini561034
 
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
SHIVA101531
 

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

More from 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#.pdf
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 
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
amarndsons
 

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

Recently uploaded

Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 

Recently uploaded (20)

Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 

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