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...
fix this code in python and show me the output. do not change the code import...
fix this code in python and show me the output. do not change the code import random #variables and constants MAX_ROLLS = 5 MAX_DICE_VAL = 6 #declare a list of roll types ROLLS_TYPES = [ "Junk" , "Pair" , "3 of a kind" , "5 of a kind" ] #set this to the value MAX_ROLLS pdice = [0,0,0,0,0] cdice = [0,0,0,0,0] #set this to the value MAX_DICE_VAL pdice = [0,0,0,0,0,0] cdice = [0,0,0,0,0,0] #INPUT - get the dice rolls i...
C++ CODE Change your code from Part A to now present a menu to the user...
C++ CODE Change your code from Part A to now present a menu to the user asking them for an operation to perform on the text that was input. You must include the following functions in your code exactly as provided. Additionally, you must have function prototypes and place them above your main function, and the function definitions should be placed below the main function. Your program should gracefully exit if the user inputs the character q or sends the...
The NASW Code of Ethics serves to do all of the following except A. Guide practitioners...
The NASW Code of Ethics serves to do all of the following except A. Guide practitioners in resolving practice dilemmas that include ethical issues B. Guide the assessment of a social worker’s professional integrity C. Guide practitioners with regard to their behavior with clients, colleagues, employers, and the community D. Direct the practice of the social worker along rigid laws
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT