C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 20, Problem 20.14E
Program Plan Intro
Program Plan:
- Use the class hierarchy created in Exercise 19.10.
- Add user interaction part by allowing users to input the amount being credited or debited.
- Modify the information provisioning functionality by informing about the account balance after each interaction based on the account type.
Program Description:
We will have three classes Account, SavingsAccount and CheckingAccount with desired attributes and operations. We will re-use the class hierarchy created in Exercise 19.10 and make use of virtual functions for implementing credit and debit operations. Usage of virtual functions and overridden methods in the hierarchy will demonstrate dynamic polymorphism and reduce the code overhead significantly.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
.“Dangling and wild pointers are known to be problems with pointers”. Justify the given statement with the helpof suitable example
Write in C++ Language.
(Employee Record): Create a class named 'Staff' having the following members: Data members - Id – Name - Phone number – Address - AgeIt also has a function named 'printSalary' which prints the salary of the staff.Two classes 'Employee' and 'Officer' inherits the 'Staff' class. The 'Employee' and 'Officer' classes have data members 'Top Skill' and 'department' respectively. Now, assign name, age, phone number, address and salary to an employee and a officer by making an object of both of these classes and print the same.
(Payroll System Modification) Modify the payroll system of Figs. 20.9–20.17 to includeprivate data member birthDate in class Employee. Use class Date from Figs. 18.6–18.7 to representan employee’s birthday. Assume that payroll is processed once per month. Create a vector of Employee references to store the various employee objects. In a loop, calculate the payroll for each Employee (polymorphically), and add a $100.00 bonus to the person’s payroll amount if the currentmonth is the month in which the Employee’s birthday occurs.
Chapter 20 Solutions
C How to Program (8th Edition)
Ch. 20 - Prob. 20.3ECh. 20 - (Polymorphism vs. switch logic) Discuss the...Ch. 20 - (Inheriting Interface vs. Implementation)...Ch. 20 - Prob. 20.6ECh. 20 - (Dynamic Binding vs. Static Binding) Distinguish...Ch. 20 - Prob. 20.8ECh. 20 - (Abstract Base Classes) Suggest one or more levels...Ch. 20 - Prob. 20.10ECh. 20 - (Polymorphic Application) Youve been asked to...Ch. 20 - (Payroll System Modification) Modify the payroll...
Knowledge Booster
Similar questions
- C++ Programming. Topic: Working with pointers and dynamic memory. Indicators. Working with dynamic memory. Dynamic arrays and their use as function parameters. Task : Describe a void function named Swap(x,y) that swaps the values stored in the variables x and (x is a real type parameter and is both input and output). Using this function , for the given variables of real type a, b, c, d, one should sequentially replace the values of the pairs (a, b), (c, d) and (b, c) and let a, b, c, d be new values .arrow_forward(Package Inheritance Hierarchy) Use the Package inheritance hierarchy created inExercise 19.9 to create a program that displays the address information and calculates the shippingcosts for several Packages. The program should contain a vector of Package pointers to objects ofclasses TwoDayPackage and OvernightPackage. Loop through the vector to process the Packagespolymorphically. For each Package, invoke get functions to obtain the address information of thesender and the recipient, then print the two addresses as they would appear on mailing labels. Also,call each Package’s calculateCost member function and print the result. Keep track of the totalshipping cost for all Packages in the vector, and display this total when the loop terminates.arrow_forward[In c#] Write a class with name Arrays . This class has an array which should be initialized by user.Write a method Sum that should sum even numbers in array and return sum. write a function with name numFind in this class with working logic as to find the mid number of an array. After finding this number calculate its factorial.Write function that should display sum and factorial.Don’t use divide operatorarrow_forward
- write in c++ Write ONE program that contains the following (#includes are NOT necessary). [Hint: be very careful with your pointer syntax] Write a function copies with two int parameters, named n and x. It should dynamically allocate a new array of size n. The function should then copy the value in x to every position in the array. The function should return a pointer to the new array. In the main function, call the copies function from part 1. with size 5 and value -1. Output the resulting array to the screen, and deallocate the array. In your main function, add code to declare and initialize two integer variables y and z to 10 and 3. Then call the function increment which has the prototype below. The call should result in incrementing the value in y by z (so y will become 13). void increment (int *a, int b); //do NOT define this function// this function adds b to the value pointed to by the first argumentarrow_forward(Modifying Class GradeBook) Modify class GradeBook (Figs. 16.11–16.12) as follows:a) Include a second string data member that represents the course instructor’s name.b) Provide a set function to change the instructor’s name and a get function to retrieve it.c) Modify the constructor to specify course name and instructor name parameters.d) Modify function displayMessage to output the welcome message and course name,then the string "This course is presented by: " followed by the instructor’s name.Use your modified class in a test program that demonstrates the class’s new capabilities.arrow_forward(Q6) This is a Data Structures problem and the programming language used is Lisp. Solve the question we detailed steps and make it concise and easy to understand. Please and thank you. Can you please explain this question specifically what you are doing in each step because it is a very confusing topic. Thanks!arrow_forward
- (Dynamic Binding vs. Static Binding) Distinguish between static binding and dynamicbinding. Explain the use of virtual functions and the vtable in dynamic bindingarrow_forwardUSE PYTHON PROGRAMMING LANGUAGE(OOP) 1. (Geometry: n-sided regular polygon) An n-sided regular polygon’s sides all have the same length and all of its angles have the same degree (i.e., the polygon is both equilateral and equiangular). Design a class named RegularPolygon that contains: ■ A private int data field named n that defines the number of sides in the polygon. ■ A private float data field named the side that stores the length of the side. ■ A private float data field named x that defines the x-coordinate of the center of the polygon with a default value 0. ■ A private float data field named y that defines the y-coordinate of the center of the polygon with a default value 0. ■ A constructor that creates a regular polygon with the specified n (default 3), side (default 1), x (default 0), and y (default 0). ■ The accessor and mutator methods for all data fields. ■ The method getPerimeter() returns the perimeter of the polygon. ■ The method getArea() returns the area of the…arrow_forward*Use original work!! or will downvote* INSTRUCTIONS: In this assignment, you will make your own smart pointer type. You will write the following class to develop a referenced counted smart pointer. You will also implement a few other member functions to resemble the functionality of an ordinary raw pointer. Basically, this is a problem of designing a single, non-trivial class and overloading a few pointer related operators. You may not use any of the STLs except for stdexcept, to do this, i.e., please dont try and use a shared_ptr to implement the class. You can start with this code, and you may add other member functions, if you want. C++ LANGUAGE Only need smart_ptr.h file. *Use original work!! or will downvote*arrow_forward
- 4A in Python language please:arrow_forwardC programming / Finding areaarrow_forward(CP6) Write a function that is passed an array of structs and performs calculations. The function should locate the highest gpa from a group of students. The function is passed the array of structs, the first element to be searched, and the last element to be searched. The return value of the function is the highest gpa in the search range. struct data{ string name; double gpa;}; double highestGpa( data [ ], int, int ); data [ ] - array of structs to search int - first element to be searched int - last element to be searched return - highest gpa from grouparrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education