Program:Write a template class, named tenForward, make an instance of it as type integer - make a sorted list of values from 1 to 10 using the C++ random number generator. Insert the numbers into the...

1 answer below »
Program:Write a template class, named tenForward, make an instance of it as type integer - make a sorted list of values from 1 to 10 using the C++ random number generator. Insert the numbers into the linked list of random values in order the random number generator created them. The node of the list will contain the number and how many times the number was attempted to be added to the list. If the value is already in the list only add the number of occurrences, if not in the list - add to the random order list and the ascending ordered number list (list obviously in ascending order). tenForward will contain structs and appropriate methods to add, print, etc. items. Make sure appropriate constructor and destructor members are written. struct randomNode{ int randomNumber; //remember to change the structs to use the template data type int occurrences; node * next;};struct AscendingOrderedNode{ int orderedNumber; node * next;};You are not allowed to prepopulate either linked list.v1 = rand() % 100; // v1 in the range 0 to 99v2 = rand() % 100 + 1; // v2 in the range 1 to 100v3 = rand() % 30 + 1985; // v3 in the range 1985-2014/* initialize random seed: */ srand (time(NULL));/* generate secret number between 1 and 10: */ randomNbr = rand() % 10 + 1;Display random number generated and print list as each number is checked to see if already in the list, print list of ordered values. When all values have been added display the total number of random numbers generated to get the full list of values 1 – 10.2Random sequence from random number generator 5 8 7 5 1 .... (keep generating until 1 – 10 generated)Random number: 55 not in listRandom order:5 - 1 occurrenceOrdered ascending:5Random number: 88 not in listRandom order:5 - 1 occurrence8 – 1 occurrence Ordered ascending:5 8Random number: 77 not in listRandom order:5 - 1 occurrence8 - 1 occurrence7 - 1 occurrence Ordered ascending:5 7 8 Random number: 55 already in listRandom order:5 - 2 occurrences7 - 1 occurrence8 - 1 occurrence Ordered ascending:5 7 8 Random number: 11 not in listRandom order:5 - 2 occurrences7 - 1 occurrence8 - 1 occurrence 1 - 1 occurrence Ordered ascending:1 5 7 83Create instance of template class tenBackward. Create integer instance of it, use a copy constructor that will deep copy the random list from the tenForward class. Use a member function to take the random list in the tenBackward class and create a linked list in descending order. Print values accordingly.Random order list: 5 8 7 5 1 ....Random number: 55 not in listRandom order:5 - 1 occurrenceOrdered descending:5Random number: 88 not in listRandom order:5 - 1 occurrence8 – 1 occurrence Ordered descending:8 5Random number: 77 not in listRandom order:5 - 1 occurrence8 - 1 occurrence7 - 1 occurrence Ordered descending:8 7 5 Random number: 55 already in listRandom order:5 - 2 occurrences7 - 1 occurrence8 - 1 occurrence Ordered descending:8 7 5 Random number: 11 not in listRandom order:5 - 2 occurrences7 - 1 occurrence8 - 1 occurrence 1 - 1 occurrence Ordered descending:8 7 5 1In addition, the results should be printed out in main( ) routine to the screen and to an output file (out.txt). 4Perform the program again – this time the data type is character and the user will enter values lower case letters a – z (do not let the user enter any other character – error message and reenter) instead of numbers from the random number generator. Stop when a total of 10 distinct characters have been entered. HINT: make two input methods – random numbers and user entered characters – then based on the appropriate template int or char and call associated input method
Answered 84 days AfterNov 12, 2021

Answer To: Program:Write a template class, named tenForward, make an instance of it as type integer - make a...

Neha answered on Jan 03 2022
121 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here