bartleby

Concept explainers

Question
Book Icon
Chapter 17, Problem 10PC
Program Plan Intro

Payroll Modification

Program Plan:

LinkedList.h:

  • Include the required specifications into the program.
  • Define a class template named “LinkedList”.
    • Declare the member variables “value” and “*next” in structure named “ListNode”.
    • Declare the pointer variables “head” and “placeHolder” for the structure.
    • Declare the constructor, copy constructor, destructor, and member functions in the class.
  • Declare a class template and define a function named “appendNode()” to insert the node at end of the list.
    • Declare the structure pointer variables “newNode” and “nodePtr” for the structure named “ListNode”.
    • Assign the value “newValue” to the variable “newNode” and assign null to the variable “newNode”.
    • Using “if…else” condition check whether the list to be empty or not, if the “head” is empty and make a new node into “head” pointer. Otherwise, make a loop find last node in the loop.
    • Assign the value of “nodePtr” into the variable “newNode”.
  • Declare a class template and define a function named “displayList()” to print the values in the list.
    • Declare the structure pointer “nodePtr” for the structure named “ListNode”.
    • Initialize the variable “nodePtr” with the “head” pointer.
    • Make a loop “while” to display the values of the list.
  • Declare a class template and define a function named “insertNode()” used to insert a value into the list.
    • Declare the structure pointer variables “newNode”, “nodePtr”, and “previousNode” for the structure named “ListNode”.
    • Make a “newNode” value into the received variable value “newValue”.
    • Using “if…else” condition to check whether the list is empty or not.
      • If the list is empty then initialize “head” pointer with the value of “newNode” variable.
      • Otherwise, make a “while” loop to test whether the “newValue” value is less than the list values or not.
      • Use “if…else” condition to initialize the value into list.
  • Declare a class template and define a function named “deleteNode()” to delete a value from the list.
    • Declare the pointer variables “nodePtr”, and “previousNode” for the structure named “ListNode”.
    • Using “if…else” condition to check whether the “head” value is equal to “newValue” or not.
      • Initialize the variable “nodePtr” with the value of the variable “head”.
      • Remove the value using “delete” operator and reassign the “head” value into the “nodePtr”.
      • If the “newValue” value not equal to the “head” value, then define the “while” loop to assign the “nodePtr” into “previousNode”.
      • By using “if” condition, delete the “previousNode” pointer.
  • Define the destructor to destroy the values in the list.
    • Declare the structure pointer variables “nodePtr”, and “nextNode” for the structure named “ListNode”.
    • Initialize the “head” value into the “nodePtr”.
    • Define a “while” loop to make the links of node into “nextNode” and remove the node using “delete” operator.
  • Declare a class template and define a function named “getFirst()” to get a  first value from the list.
    • Declare a variable “status” in type of “boolean” and initialize the “head” value into the “placeHolder”.
    • Change the value of “status” into “true”, if the value available in “placeHolder”.
    • Return the value of “status” into called function.
  • Declare a class template and define a function named “getNext()” to get a  another value from the list.
    • Declare a variable “status” in type of “boolean”.
    • Initialize the next node value of “placeHolder” into “placeHolder”.
    • Change the value of “status” into “true”, if the next node value available in “placeHolder”.
    • Return the value of “status” into called function.

main.cpp:

  • Include the required header files into the program.
  • Declare the function prototypes to get employee information from user.
  • In “main()” function, create a object for “LinkedList” template class.
  • Define the function named “getEmployeeIds()” with an object of “LinkedList” class.
    • Declare the variable named “anotherOne” and initialize it as “y”.
    • Declare the variable named “id” in type of “long”.
    • Make a call to the function “appendNode()” with value of “id”.
    • Prompt the user to get another value from user.
  • Define the function named “getEmployeeInfo()” with an object of “LinkedList” class.
    • Declare the variables named “idNum”, “hours”, “payRate”, and “grossPay”.
    • Using “if…else” condition check whether the list is empty or not.
      • If list contains data, make a call to a function “getData()” to get the values from user.
        • Make a call to “appendNode” using objects; insert the values into the list.
      • Otherwise, display appropriate message on the screen.
  • Define the function named “getData()” with an arguments.
    • Prompt and get the values of “hours” and “payRate” from user to calculate the value of “grossPay”.
  • Define the function named “displayWages()” with an objects for linked list.
    • Declare the variables for the method.
    • Using “while” loop to display all values from the list.

Blurred answer
Students have asked these similar questions
Q4: Consider the following MAILORDER relational schema describing the data for a mail order company. (Choose five only). PARTS(Pno, Pname, Qoh, Price, Olevel) CUSTOMERS(Cno, Cname, Street, Zip, Phone) EMPLOYEES(Eno, Ename, Zip, Hdate) ZIP CODES(Zip, City) ORDERS(Ono, Cno, Eno, Received, Shipped) ODETAILS(Ono, Pno, Qty) (10 Marks) I want a detailed explanation to understand the mechanism how it is Qoh stands for quantity on hand: the other attribute names are self-explanatory. Specify and execute the following queries using the RA interpreter on the MAILORDER database schema. a. Retrieve the names of parts that cost less than $20.00. b. Retrieve the names and cities of employees who have taken orders for parts costing more than $50.00. c. Retrieve the pairs of customer number values of customers who live in the same ZIP Code. d. Retrieve the names of customers who have ordered parts from employees living in Wichita. e. Retrieve the names of customers who have ordered parts costing less…
Q4: Consider the following MAILORDER relational schema describing the data for a mail order company. (Choose five only). (10 Marks) PARTS(Pno, Pname, Qoh, Price, Olevel) CUSTOMERS(Cno, Cname, Street, Zip, Phone) EMPLOYEES(Eno, Ename, Zip, Hdate) ZIP CODES(Zip, City) ORDERS(Ono, Cno, Eno, Received, Shipped) ODETAILS(Ono, Pno, Qty) Qoh stands for quantity on hand: the other attribute names are self-explanatory. Specify and execute the following queries using the RA interpreter on the MAILORDER database schema. a. Retrieve the names of parts that cost less than $20.00. b. Retrieve the names and cities of employees who have taken orders for parts costing more than $50.00. c. Retrieve the pairs of customer number values of customers who live in the same ZIP Code. d. Retrieve the names of customers who have ordered parts from employees living in Wichita. e. Retrieve the names of customers who have ordered parts costing less than$20.00. f. Retrieve the names of customers who have not placed…
ut da Q4: Consider the LIBRARY relational database schema shown in Figure below a. Edit Author_name to new variable name where previous surname was 'Al - Wazny'. Update book_Authors set Author_name = 'alsaadi' where Author_name = 'Al - Wazny' b. Change data type of Phone to string instead of numbers. عرفنه شنو الحل BOOK Book id Title Publisher_name BOOK AUTHORS Book id Author_name PUBLISHER Name Address Phone e u al b are rage c. Add two Publishers Company existed in UK. insert into publisher(name, address, phone) value('ali','uk',78547889), ('karrar', 'uk', 78547889) d. Remove all books author when author name contains second character 'D' and ending by character 'i'. es inf rmar nce 1 tic عرفته شنو الحل e. Add one book as variables data? عرفته شنو الحل

Chapter 17 Solutions

Starting Out with C++ from Control Structures to Objects, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (8th Edition)

Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT