Question

In: Computer Science

C++: Do not change anything in the supplied code below that will be the Ch16_Ex5_MainProgram.cpp except...

C++:

Do not change anything in the supplied code below that will be the Ch16_Ex5_MainProgram.cpp except to add documentation. PLEASE DO NOT CHANGE THE CODE JUST ADD DOCUMENTATION. Thank you. The last few have changed the code. Appreciate you all.
Please use the file names listed below since your file will have the following components:

Ch16_Ex5_MainProgram.cpp - given file


//22 34 56 4 19 2 89 90 0 14 32 88 125 56 11 43 55 -999

#include <iostream>
#include "unorderedLinkedList.h"

using namespace std;

int main()
{
unorderedLinkedList<int> list, subList;

int num;                                                                                                                     

            cout << "Enter numbers ending with -999" << endl;                                                                                                                   
cin >> num;                                                                                                   

            while (num != -999)                                                                                        
{
list.insertLast(num);                                                                
cin >> num;                                                                                                   
}

            cout << endl;                                                                                                 

            cout << "List: ";                                              
list.print();                                                                                                      
cout << endl;                                                                                                             
cout << "Length of the list: " << list.length() << endl;                                                                                                    

            list.divideMid(subList);

            cout << "Lists after splitting list" << endl;

            cout << "list: ";
list.print();                                                                                                      
cout << endl;                                                                                                             
cout << "Length of the list: " << list.length() << endl;                

            cout << "sublist: ";
subList.print();                                                                                                
cout << endl;                                                                                                             
cout << "Length of subList: " << subList.length() << endl;
system("pause");
return 0;                                                        
}

linkedList.h
unorderedLinkedList.h

Solutions

Expert Solution

I have added documentation for your code:

//22 34 56 4 19 2 89 90 0 14 32 88 125 56 11 43 55 -999
/* The Aim of this program is takiing the values from keyboard and inserting into the lists..and
finally dividing the lsit into 2 halves and displaying lengths and values of both the lists.*/
#include <iostream>
#include "unorderedLinkedList.h" //including unorderedLinkedList.h file in this program..

using namespace std;

int main()
{
unorderedLinkedList<int> list, subList; //declaring unordered lisked lists..

int num; //declaring a number..

cout << "Enter numbers ending with -999" << endl;   
cin >> num;   

while (num != -999) //if num == -999 then while loop exits...   
{
list.insertLast(num); //inserting the number into unorderedLinkedList   
cin >> num; //again reading th number from keyboard..   
}

cout << endl;   

cout << "List: ";   
list.print(); //displaying list by print() method present inside unorderedLinkedList.
cout << endl;   
cout << "Length of the list: " << list.length() << endl; //diplaying length of unorderedLinkedList   

list.divideMid(subList); //dividing the list into two halves..one is list, other is subList..

cout << "Lists after splitting list" << endl;

cout << "list: ";
list.print(); // again displaying list..   
cout << endl;   
cout << "Length of the list: " << list.length() << endl; //displaying splitted list length..

cout << "sublist: ";
subList.print(); //dispalying sublist... valuees stored in list...   
cout << endl;   
cout << "Length of subList: " << subList.length() << endl; //displaying length of sublist..
system("pause");
return 0;
}


Related Solutions

Enter your answers in the empty code chunks. Don't change anything in the chunk below, and...
Enter your answers in the empty code chunks. Don't change anything in the chunk below, and make sure you run it before attempting any of the problems: ```{r message=FALSE, warning=TRUE} library(tidyverse) library(ggpubr) set.seed(2018) # Belgium win 3rd place in the World Cup ``` # Basics Calculate $\frac{(2+2)\times (3^2 + 5)}{(6/4)}$: ```{r basics1} # your code here ``` Create a vector called "x" with the following values: 10, 15, 18, 20. ```{r basics2} # your code here ``` Calculate the mean...
Please make my Code working and pass the test but do NOT change anything in main...
Please make my Code working and pass the test but do NOT change anything in main function, thank you. #include <iostream> using namespace std; void sort(int *A, int n){    for(int passes = 0;passes < 2;passes++) { // shift can have only two values either 0 or 16, used for shifting purpose int shift = passes * 16; int N = 1<<(16 + 1);    // Temporary array for storing frequency of upper or lower 16 bits int temp[N];   ...
C code only, not C++ or anything else // This program accepts the chest size from...
C code only, not C++ or anything else // This program accepts the chest size from the customer // and returns the proper shirt size as well as the price. // function prototype void check_size_price(int size_val, char *size_char, int *price); #include <stdio.h> int main() { int chest_size; //input - entered chest size char size_str; //output - size (S/M/L) int p; //output - price // validation loop for the input – the chest size must be a positive integer // Call...
PLEASE DO NOT CHANGE THE CODE BELOW! In this problem, we will implement an nth root...
PLEASE DO NOT CHANGE THE CODE BELOW! In this problem, we will implement an nth root finder. In particular, please fill in the findNthRoot(int number, int n, int precision) method in the class NthRootFinder. The method should return a string representing the nth root of number, rounded to the nearest precision decimal places. If your answer is exact, you should fill in the answer with decimal places (i.e. with input 41 and precision 5, we should return 41.00000.) You may...
Below is my c program code you have to change all the functions names variables name...
Below is my c program code you have to change all the functions names variables name , every thing so it wont look same but runs the same and make sure you run the program and share the output so i get to know that the program is running thank you. #define _CRT_SECURE_NO_DEPRECATE #include #include #include #include #include struct patient { int id; int age; bool annualClaim; int plan; char name[30]; char contactNum[15]; char address[50]; }; #define MAX_LENGTH 500 struct...
Convert the attached C++ code to working Java code. Be judicious in the change that you...
Convert the attached C++ code to working Java code. Be judicious in the change that you make. This assignment is not about re-writing or improving this code, but rather about recognizing the differences between C++ and Java, and making the necessary coding changes to accommodate how Java does things. PLEASE DO NOT use a built-in Java QUEUE (or any other) container. Additional resources for assignment: #include <iostream> #include <string> using namespace std; class pizza { public: string ingrediants, address; pizza...
Explain the difference between a change in supply and a change in quantity supplied. Illustrate with...
Explain the difference between a change in supply and a change in quantity supplied. Illustrate with a suitable example
a) Distinguish between a change in quantity supplied and a change in supply. Include diagrams and...
a) Distinguish between a change in quantity supplied and a change in supply. Include diagrams and a written explanation in your answer...( 4 marks ) (b) In the current Covid-19 real estate market, people have different ideas on where the market is going. Homebuyers expect the price of new homes to fall over the next year. Homesellers expect the price of new home to rise. Question: Explain how the market for new homes will be affected. You can use a...
What is the difference between a change in supply and a change in quantity supplied? What...
What is the difference between a change in supply and a change in quantity supplied? What is the law of supply? What are the main variables that will cause a supply curve to shift? Please give an example of each.
Discuss and illustrate graphically the difference between a change in quantity supplied and a change in...
Discuss and illustrate graphically the difference between a change in quantity supplied and a change in supply. 8.         List and discuss the factors that shift supply. Illustrate graphically. 9.         Define, discuss and illustrate graphically equilibrium in the olive market. Define and illustrate graphically excess demand and excess supply.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT