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
8. Grade Book A teacher has five students who have taken four tests. The teacher uses the following grading scale to assign a letter grade to a student, based on the average of his or her four test scores: Test Score Letter Grade 90–100 A 80-89 B 70-79 C 60-69 D 0-59 Write a class that uses a String array or an ArrayList object to hold the five students' names, an array of five characters to hold the five students' letter grades, and five arrays of four doubles each to hold each student's set of test scores. The class should have methods that return a specific student's name, the average test score, and a letter grade based on the average. Demonstrate the class in a program that allows the user to enter each student's name and his or her four test scores. It should then display each student's average test score and letter grade. Input Validation: Do not accept test scores less than zero or greater than 100.
Program Name: <LastNameFirstInit>_PetShelter You work at a Pet Shelter that take in homeless pets. You have been tasked with creating a report that shows a list of all the dog breeds currently staying at the shelter. This list should include the breed name along with the count for each breedcurrently being housed at the shelter. In addition, at the end, the report should display the name of breed that we have the most (max) of currently at the shelter. In addition, your program should utilize methods for building the report and searching for the max breed count. Two parallel arrays have been provided. You can use the following code to get you started. //START CUTTING CODE HERE public class MichakR_PetShelter { public static void main(String[] args) { String[] breedNames = {"Bulldog", "German Shepherd", "Golden Retriever", "Beagle", "Poodle", "Boxer", "Mixed Dog", "Husky"}; int[] breedCounts = {2,5,3,1,8,1,11, 3};   //generate report   //get Max Breed   //print report   }   public…
Drink Machine Simulator Write a program that simulates a soft drink machine. The program should use a structure that stores the following data: Drink Name Drink Cost Number of Drinks in Machine The program should create an array of five structures. The elements should be initialized with the following data: Drink Name Cost Number in Machine Cola .75 20 Root Beer .75 20 Lemon-Lime .75 20 Grape Soda .80 20 Cream Soda .80 20 Each time the program runs, it should enter a loop that performs the following steps: A list of drinks is displayed on the screen. The user should be allowed to either quit the program or pick a drink. If the user selects a drink, he or she will next enter the amount of money that is to be inserted into the drink machine. The program should display the amount of change that would be returned, and subtract one from the number of that drink left in the machine. If the user selects a drink that has sold out, a message…

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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr