Starting Out with C++ from Control Structures to Objects Plus MyLab Programming with Pearson eText -- Access Card Package (9th Edition)
9th Edition
ISBN: 9780134544847
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
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.
- If list contains data, make a call to a function “getData()” to get the values from user.
- 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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents 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)
Ch. 18.1 - Prob. 18.1CPCh. 18.1 - Prob. 18.2CPCh. 18.1 - Prob. 18.3CPCh. 18.1 - Prob. 18.4CPCh. 18.2 - Prob. 18.5CPCh. 18.2 - Prob. 18.6CPCh. 18.2 - Prob. 18.7CPCh. 18.2 - Prob. 18.8CPCh. 18.2 - Prob. 18.9CPCh. 18.2 - Prob. 18.10CP
Ch. 18 - Prob. 1RQECh. 18 - Prob. 2RQECh. 18 - Prob. 3RQECh. 18 - Prob. 4RQECh. 18 - Prob. 5RQECh. 18 - Prob. 6RQECh. 18 - Prob. 7RQECh. 18 - Prob. 8RQECh. 18 - Prob. 9RQECh. 18 - Prob. 10RQECh. 18 - Prob. 11RQECh. 18 - Prob. 12RQECh. 18 - Prob. 13RQECh. 18 - Prob. 14RQECh. 18 - Prob. 15RQECh. 18 - Prob. 16RQECh. 18 - Prob. 17RQECh. 18 - Prob. 18RQECh. 18 - Prob. 19RQECh. 18 - Prob. 20RQECh. 18 - Prob. 21RQECh. 18 - Prob. 22RQECh. 18 - Prob. 23RQECh. 18 - Prob. 24RQECh. 18 - Prob. 25RQECh. 18 - T F The programmer must know in advance how many...Ch. 18 - T F It is not necessary for each node in a linked...Ch. 18 - Prob. 28RQECh. 18 - Prob. 29RQECh. 18 - Prob. 30RQECh. 18 - Prob. 31RQECh. 18 - Prob. 32RQECh. 18 - Prob. 33RQECh. 18 - Prob. 34RQECh. 18 - Prob. 35RQECh. 18 - Prob. 1PCCh. 18 - Prob. 2PCCh. 18 - Prob. 3PCCh. 18 - Prob. 4PCCh. 18 - Prob. 5PCCh. 18 - Prob. 6PCCh. 18 - Prob. 7PCCh. 18 - List Template Create a list class template based...Ch. 18 - Prob. 9PCCh. 18 - Prob. 10PCCh. 18 - Prob. 11PCCh. 18 - Prob. 12PCCh. 18 - Prob. 13PCCh. 18 - Prob. 14PCCh. 18 - Prob. 15PC
Knowledge Booster
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
- Task 3: Statistics using arrays: by java programming With the spread of COVID 19, the HR department in a company has decided to conduct some statistics among the employees in order to determine the number of infections according to some conditions. For each employee, they have to record the code, name, age, whether he/she was infected or no and the remaining days of leaves for him/her. You are requested to write the program that maintains the lists of details for the employees as mentioned above using the concept of arrays. The program repeats the display of a menu of services until the user decides to exit. 1. Start by initializing the employee details by reading them from the keyboard. 2. Repeat the display of a menu of 4 services, perform the required task according to the user’s choice and asks the user whether he/she wants to repeat or no. You need to choose one service from each category (‘A’,’B’,’C’,’D’) a. A. Display the total number of employees that were infected b. B.…arrow_forwardignore the 4a is actually the previous I donearrow_forwardQuestion > Not complete Marked out of 1.50 Flag question Previous page Write a recursive function named get_palindromes (words) that takes a list of words as a parameter. The function should return a list of all the palindromes in the list. The function returns an empty list if there are no palindromes in the list or if the list is empty. For example, if the list is ["racecar", "hello", "noon", "goodbye"], the function should return ["racecar", "noon"]. A palindrome is a word that is spelled the same forwards and backwards. Note: The get_palindromes() function has to be recursive; you are not allowed to use loops to solve this problem. For example: Test words = ["racecar", "hello", "noon", "goodbye", "test", 'aibohphobia'] ['racecar', 'noon', 'aibohphobia'] print (get_palindromes (words)) print (get_palindromes ([])) print (get_palindromes (['this', 'is', 'test'])) Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) Result Precheck Check [] [] Next pagearrow_forward
- Pseudocode for the student grade calculator program, please Create a program to enter grades and calculate averages and letter grades. Need a class which will contain: Student Name Student Id Student Grades (an array of 3 grades) A constructor that clears the student data (use -1 for unset grades) Get functions for items a, b, and c, average, and letter grade Set functions for items a, n, and c Note that the get and set functions for Student grades need an argument for the grade index. Need another class which will contain: An Array of Students (1 above) A count of number of students in use You need to create a menu interface that allows you to: Add new students Enter test grades Display all the students with their names, ids, test grades, average, and letter grade Exit the program Add comments and use proper indentation. Nice Features: I would like that system to accept a student with no grades, then later add one or more grades, and when all grades are entered, calculate the…arrow_forwardC++ language Write a program that asks the user to enter daily sale for five stores and record them in an array.The program should then display a bar graph comparing each store’s sales for all days of a week.Create each bar in the bar graph by displaying a row of asterisks. Each asterisk should representRs.1000 of sales. The program also calculates the total sale each day, and total sale of the week.Here is an example of the program s output.Enter day 1 sales for store 1: 4000 [Enter]Enter day 1 sales for store 2: 6000 [Enter]Enter day 1 sales for store 3: 10000 [Enter]Enter day 1 sales for store 4: 11000 [Enter] Enter day 1 sales for store 5: 3000 [Enter]Enter day 2 sales for store 1: 9000 [Enter]Enter day 2 sales for store 2: 8000 [Enter]Enter day 2 sales for store 3: 19000 [Enter]Enter day 2 sales for store 4: 7000 [Enter]Enter day 2 sales for store 5: 9000 [Enter]…(and so on.)Weekly SaleMonday: Total Sale: 34,000/-Store 1: **** (4000)Store 2: ****** (6000)Store 3: **********…arrow_forwardArithmetic progression def arithmetic_progression(items): An arithmetic progression is a numerical sequence so that the stride between each two consecutive elements is constant throughout the sequence. For example, [4, 8, 12, 16, 20] is an arithmetic progression of length 5, starting from the value 4 with a stride of 4.Given a non-empty list items of positive integers in strictly ascending order, find and return the longest arithmetic progression whose all values exist somewhere in that sequence. Return the answer as a tuple (start, stride, n) of the values that define the progression. To ensure unique results to facilitate automated testing, if there exist several progressions of the same length, this function should return the one with the lowest start. If several progressions of equal length emanate from the lowest start, return the progression with the smallest stride. items Expected result [42] (42, 0, 1) [2, 4, 6, 7, 8, 12, 17] (2, 2, 4) [1, 2, 36, 49, 50, 70, 75, 98,…arrow_forward
- Arithmetic progression def arithmetic_progression(items): An arithmetic progression is a numerical sequence so that the stride between each two consecutive elements is constant throughout the sequence. For example, [4, 8, 12, 16, 20] is an arithmetic progression of length 5, starting from the value 4 with a stride of 4. Given a non-empty list items of positive integers in strictly ascending order, find and return the longest arithmetic progression whose all values exist somewhere in that sequence. Return the answer as a tuple (start, stride, n) of the values that define the progression. To ensure unique results to facilitate automated testing, if there exist several progressions of the same length, this function should return the one with the lowest start. If several progressions of equal length emanate from the lowest start, return the progression with the smallest stride. items expected results [42] (42, 0, 1) [2, 4, 6, 7, 8, 12, 17] (2, 2, 4) [1, 2, 36, 49, 50, 70, 75, 98,…arrow_forward7. Quarterly Sales Statistics Write a program that lets the user enter four quarterly sales figures for six divisions of a company. The figures should be stored in a two-dimensional array. Once the figures are entered, the program should display the following data for each quarter: • A list of the sales figures by division • Each division's increase or decrease from the previous quarter (this will not be dis- played for the first quarter) The total sales for the quarter • The company's increase or decrease from the previous quarter (this will not be dis- played for the first quarter) • The average sales for all divisions that quarter • The division with the highest sales for that quarter Input Validation: Do not accept negative numbers for sales figures.arrow_forwardC Program / C Language Make a C program for the rank order from highest to lowest of the array.arrow_forward
- Alphabet Random Walk• Write a program to generate a random walk that spans a 10*10 character array (The initial values of the elements are all.). The program must randomly walk from one element to another, moving one element position up, down, left or right each time. The elements that have been visited are labeled with the letters A through Z in the order in which they were visitedarrow_forwardflip_matrix(mat:list)->list You will be given a single parameter a 2D list (A list with lists within it) this will look like a 2D matrix when printed out, see examples below. Your job is to flip the matrix on its horizontal axis. In other words, flip the matrix horizontally so that the bottom is at top and the top is at the bottom. Return the flipped matrix. To print the matrix to the console: print('\n'.join([''.join(['{:4}'.format(item) for item in row]) for row in mat])) Example: Matrix: W R I T X H D R L G L K F M V G I S T C W N M N F Expected: W N M N F G I S T C L K F M V H D R L G W R I T X Matrix: L C S P Expected: S P L C Matrix: A D J A Q H J C I Expected: J C I A Q H A D Jarrow_forwardCode in Perl Create an array which holds a list of Video Games, consisting of title, the year it was released (guess if you don’t know) , platform (NES, XBOX One, etc) and publisher (in that order). Add at least ten albums to the list. Then, use the split function and a for or foreach loop to display the publisher followed by the title and platform for each list element.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr