Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your task for this part of the lab is to use the standard library to create 4 di

ID: 3917479 • Letter: Y

Question

Your task for this part of the lab is to use the standard library to create 4 different linked lists: language C++

1. Integer list 2. Float list 3. String list 4. A cellphone Contact list including name, telephone number, address, and further notes.

Start:

1) Create the integer, and string lists as empty lists. Add 6 elements each to the lists based on: • The numerical order of the integer (between 1 and 10) • Alphabetical order of the string list

2) Create one more list of 1000 elements, all of them with the value 78.15.

3) Next, “push” 0 to the beginning and 15 to the end of the integer list.

4) Insert your name to the middle of the string list (at location 4) using the insert() functions

5) Add 2 to the first integer in the list and subtract 4 from the last integer in your integer list.

6) Iterate thorough your string linked list to print the values in the list.

7) Create and fill the cellphone-contact list with 500 names. Use the Random Number Generator to create First/Family names. For phone numbers, keep the area code 757 and again, use the random number generator to generate phone numbers for the contacts.

8) Lastly, sort the integer list and then reverse it

Explanation / Answer

#include <iostream>

#include<stdlib.h>

#include <list>

#include <iterator>

using namespace std;

struct telephone{

string name;

string number;

string address;

string notes;

};

void random_name(char *s, const int len) {

static const char alphanum[] =

"0123456789"

"ABCDEFGHIJKLMNOPQRSTUVWXYZ"

"abcdefghijklmnopqrstuvwxyz";

for (int i = 0; i < len; ++i) {

s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];

}

  

}

void random_number(char *s, const int len) {

static const char alphanum[] ="0123456789";

for (int i = 0; i < len; ++i) {

s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];

}

  

}

int main()

{

string str;

list <int> Integer_List;

list <string> String_List;

list <float> Float_List;

list <struct telephone> Telephone_List;

  

for(int i=0;i,6;i++){

Integer_List.push_back(i+1);

cout<<"Enter string : ";

cin>>str;

String_List.push_back(str);

}

for(int i=0;i<1000;i++){

Float_List.push_back(78.15);

}

Integer_List.push_front(0);

Integer_List.push_back(15);

cout<<"Enter your name : ";

cin>>str;

list <string> :: iterator it;

it=String_List.begin();

for(int i=1;i<4;i++)it++;

String_List.insert(it,str);

list <int> :: iterator it1;

it1=Integer_List.begin();

*it1+2;

for(int i=1;i<8;i++)it1++;

*it1-4;

for(it = String_List.begin(); it != String_List.end(); ++it)

cout << ' ' << *it;

cout << ' ';

  

char name[10];

  

for(int i=0;i<500;i++){

struct telephone t;

random_name(name,10);

t.name=name;

random_number(name,10);

t.number=name;

random_name(name,10);

t.notes=name;

random_name(name,10);

t.address=name;

Telephone_List.push_back(t);

}

Integer_List.sort();

Integer_List.reverse();

return 0;

}

for any query please comment.