bartleby

Concept explainers

Question
Book Icon
Chapter 18, 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
Question: struct node  {  char *name;  int marks;  node *next;  };  By using the above declaration for the Linked List, write a program in C++ to display the summary report regarding the pass/fail ratio of the subject Data Structure for the class BSI-3 that have only 15 students.  The required Report Summary for the exam will be like wise:  The No. of A grades........???  The No. of B grades........???  And so on by applying the grading criteria of COMSATS-University Islamabad. Question: struct node  {  char *name;  int marks;  node *next;  };  By using the above declaration for the Linked List, write a program in C++ to display the summary report regarding the pass/fail ratio of the subject Data Structure for the class BSI-3 that have only 15 students.  The required Report Summary for the exam will be like wise:  The No. of A grades........???  The No. of B grades........???  And so on by applying the grading criteria of COMSATS-University Islamabad.
C++ function Linked list   Write a function, to be included in an unsorted linked list class, called replaceItem, that will receive two parameters, one called olditem, the other called new item. The function will replace all occurrences of old item with new item (if old item exists !!) and it will return the number of replacements done.
Data Structure Using C++ (Recursion) Need C++ Code :::  DON'T USE STACK PLEASE JUST Recursion This is a one question >>> 6 function in one code ....... don't use cin please  Without using stack just Recursion please  Write the following recursive functions once for an array and once for simply linked list (as member functions)1. to print all odd elements in backwards order.2. to count number of values that are below 10.3. to find maximum value. Run your functions on the following array  2,7,12,5,0,3,44,1,26and the following list 4,1,10,3,0,5,24,7,40 6 functions 3 for simply linked list and 3 for array  like picture need please

Chapter 18 Solutions

Starting Out with C++ from Control Structures to Objects Plus MyLab Programming with Pearson eText -- Access Card Package (9th 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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr