Osman 42 21.0 Y N Nick Miller 20 20.0 Y N Jeff Schitte 33 25.0 N N John King 20 32.0 Y N Brian Nguyen 42 40.0 N Y Cheryl Ray 23 40.0 N N Chelsea Smith 39 25.0 Y Y Matt Brighter 50 12.0 N

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question

 

“LinkedList.txt” listed below

 

John Wills 45 18.0 N Y

Hank Tom 20 12.0 Y Y

Willam Osman 42 21.0 Y N

Nick Miller 20 20.0 Y N

Jeff Schitte 33 25.0 N N

John King 20 32.0 Y N

Brian Nguyen 42 40.0 N Y

Cheryl Ray 23 40.0 N N

Chelsea Smith 39 25.0 Y Y

Matt Brighter 50 12.0 N Y

Victor Zhang 29 30.0 Y Y

Sean Kingston 30 31.0 N Y

John Wallace 29 15.0 Y N

Natalie Murphy 35 22.0 N Y

Russel Green 37 20.0 Y N

Derek Jeter 32 20.0 N N

Pascal Pedro 39 50.0 Y N

Kenneth Grant 29 32.0 N N

Stefanie Barajas 35 30.0 Y N

Kimberyl Allen 15 15.0 N Y




A reference of the program used in class is provided below



#include<bits/stdc++.h>

using namespace std;

 

 

struct Employee {

    string firstName;

    string lastName;

    int numOfHours;

    float hourlyRate;

    char major[2];

    float amount;

    Employee* next;

};

 

 

void printRecord(Employee*);

void appendNode(Employee*&, Employee*);

 

 

int main() {

    int NumOfEmp = 10;

 

 

    Employee* head = nullptr;

    Employee* newNode;

 

 

    string firstNames[10];

    string lastNames[10];

    int numOfHours[10];

    float hourlyRate[10];

    char comp_sci[10];

    char comp_sec[10];

   

    cout << "Enter no.of records you want to enter: ";

    cin >> NumOfEmp;

 

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

        cout << "Enter the first name of employee " << i+1 << ": ";

        cin >> firstNames[i];

        cout << "Enter the last name of employee " << i+1 << ": ";

        cin >> lastNames[i];

        cout << "Enter the number of hours worked by employee " << i+1 << ": ";

        cin >> numOfHours[i];

        cout << "Enter the hourly rate of employee " << i+1 << ": ";

        cin >> hourlyRate[i];

        cout << "Does employee " << i+1 << " have a background in computer science? (Y/N): ";

        cin >> comp_sci[i];

        cout << "Does employee " << i+1 << " have a security clearance? (Y/N): ";

        cin >> comp_sec[i];

    }

    cout<<left<<setw(15) <<"Last Name"<<setw(15) <<"First Name"<<setw(12) <<"# of Hours"<<setw(12) <<"Hourly Rate"

    << setw(10) << "Amount"<< setw(10)<<"Comp Sci" << setw(20) << "Comp Sec" << endl;

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

        newNode = new Employee;

 

 

        newNode->firstName = firstNames[i];

        newNode->lastName = lastNames[i];

        newNode->numOfHours = numOfHours[i];

        newNode->hourlyRate = hourlyRate[i];

        newNode->major[0] = comp_sci[i];

        newNode->major[1] = comp_sec[i];

 

 

        newNode->amount = newNode->numOfHours * newNode->hourlyRate;

 

 

        if (newNode->major[0] == 'Y' || newNode->major[1] == 'Y') {

            newNode->amount = newNode->amount + 1000;

        }

        if (newNode->major[0] == 'Y' && newNode->major[1] == 'Y') {

            newNode->amount = newNode->amount + 2000;

        }

 

 

   

        newNode->next = nullptr;

 

 

        appendNode(head, newNode);

 

 

       

        printRecord(newNode);

    }

 

 

 

    ofstream outfile("Employee.txt");

    if (!outfile) {

        cerr << "Error: Output file could not be opened." << endl;

        return 1;

    }

 

 

    outfile<<left<<setw(15) <<"Last Name"<<setw(15) <<"First Name"<<setw(12) <<"# of Hours"<<setw(20) <<"Hourly Rate"

    << setw(20) << "Amount"<< setw(20)<<"Comp Sci" << setw(20) << "Comp Sec" << endl;

    Employee* current = head;

    while (current != nullptr) {

        outfile << left << setw(15) << current->lastName << setw(15) << current->firstName << setw(12) << current->numOfHours << setw(20)

        << current->hourlyRate << setw(20) << current->amount << setw(20) << current->major[0]<<setw(25)<< setw(25) << current->major[1] << endl;

        current = current->next;

    }

 

 

    outfile.close();

 

 

    return 0;

}

 

 

 

 

 

void printRecord(Employee* e) {

   

    cout << left << setw(15) << e->lastName << setw(15) << e->firstName << setw(12)

    <<e->numOfHours<<setw(12) <<e->hourlyRate<<setw(10) <<e->amount

    << setw(10) << e->major[0] << setw(10) << e->major[1]<< endl;

}

 

 

void appendNode(Employee*& head, Employee* newNode) {

    if (head == nullptr) {

        head = newNode;

    }

    else {

        Employee* current = head;

        while (current->next != nullptr) {

            current = current->next;

        }

        current->next = newNode;

    }

}



Linked Lists
Create a meu-driven linked list program, and develop and use the following menu to implement
the linked list, modifying the linked list program from the labs in class.
a. Create a linked list (need to read from the "LinkedList.txt" to create the list)
Create a new node
Append them in ascending order of Lname
b. Update data of the linked list
c. Insert a new node to the linked list
d. Delete a new node to the linked list
e. Display linked list
f. Exit
Test program with following questions
Click a to create a linked list by adding a new field, Amount; display the last two nodes
on the screen
Click b to modify all the Lname to upper case and display the first 3 nodes
Take a SS of your screen
Click b to increase the hourly rate by 10 for all CS majors and display the first 3 nodes
Click d to delete nodes whose NumOfHours are greater than 40, and display the nodes
in linked list
Take a SS of screen
Click c to add a new node with (Alex, Rodrigo, 40, 50, Y, N.) based on Amount
sequence, display linked list
Take SS of screen
Click f
Create subdirecty OW80;
Transcribed Image Text:Linked Lists Create a meu-driven linked list program, and develop and use the following menu to implement the linked list, modifying the linked list program from the labs in class. a. Create a linked list (need to read from the "LinkedList.txt" to create the list) Create a new node Append them in ascending order of Lname b. Update data of the linked list c. Insert a new node to the linked list d. Delete a new node to the linked list e. Display linked list f. Exit Test program with following questions Click a to create a linked list by adding a new field, Amount; display the last two nodes on the screen Click b to modify all the Lname to upper case and display the first 3 nodes Take a SS of your screen Click b to increase the hourly rate by 10 for all CS majors and display the first 3 nodes Click d to delete nodes whose NumOfHours are greater than 40, and display the nodes in linked list Take a SS of screen Click c to add a new node with (Alex, Rodrigo, 40, 50, Y, N.) based on Amount sequence, display linked list Take SS of screen Click f Create subdirecty OW80;
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Program is not working, some places i noticed is in the switch statement the head identifier is undefined. can someone fix this and provide the code with screanshots of their compilers like vs code in the correct format also. thank you

 

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education