Use this structure definition to create a singly-linked


Use this structure definition to create a singly-linked list.

strict Employee { string fname; string lname; double salary; Employee "next; );

You are given a data file that contains data for the three parameters in HW3Data.dat. You need to write A function of void return type named create_list that accepts the head of the list as the argument, This function needs to read the data file, read one line at a time and assign the read parameters to the structure members. How, we need to attach this structure instance as a node to the list. Use this function to assign the elements for the head node as well.

Remember, we already did this in Homework 1 problem 1. In that problem we stored the read parameters into an array of structure. Here. WE are using a linked list. The logic of reading and storing does not charge. Just think how you need attach that Item to a linked list.

A function of void return type called show_list that accepts the head of the list as the argument. In this function, you need to display the contents of all nodes in the list in the format of:

LastHame FirstHame salary
A function of void return type called insert_item that accepts the head of the list and the structure instance to insert. It should also accept the first name of the employee after which the new item needs to be inserted,
A function of void return type called delete_item that accepts the head of the list and the first name of the Employee to be deleted from the list,

To test if you program is working, use the following main function.
int main()
{
Employee *head = new Employee; //head of the list
create_list(head);
Employee *item=new Employee; //item to be inserted_item->fname =."Robert'% item->Iname="Johnson;
item->salary=75000.50;
insert_item(head,"Sheila",item);//insert after Sheila
delete_item(head, "Sheila");//delete Sheila
show_list(head); return 0;
}
You must get the following out put.

John Harris 50000
Lisa Smith 75000.5
Adam Johnson 68500.1
Robert Johnson 75000.5
Tristen Major 75800.8
Yannic Lennart 58000.6
Lorena Emil 43000
Tereza Santeri 48000

Attachment:- Data.rar

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Use this structure definition to create a singly-linked
Reference No:- TGS02595295

Now Priced at $25 (50% Discount)

Recommended (93%)

Rated (4.5/5)