Concept explainers
(Modified Account Class) Modify class Account (Fig. 3.8) to provide a member function called withdraw that withdraws money from an Account. Ensure that the withdrawal amount does not exceed the Account's balance. If it does, the balance should be left unchanged and the member function should display a message indicating "Withdrawal amount exceeded account balance." Modify class AccountTest (Fig. 3.9) to test member function withdraw.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
C++ How to Program (10th Edition)
Additional Engineering Textbook Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Starting Out With Visual C# (5th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Introduction to Programming Using Visual Basic (10th Edition)
Starting Out with C++: Early Objects
- Q2) Write C++ code to create class called number. The private data members for this class are nobl (double), nob2 (double) and nob3(double). The member function for this class is: 1- (Constructor) that accepts nobl, nob2 and nob3 as arguments (inside the class). Write a main() that create two objects (h1) with initially data members (nob1 :13000, nob2:15 and nob3 :19) , (kl) with initially data members (nob1:16000, nob2:77 and nob3:2018) and (TI) with initially data members (nob1:15000, nob2:37 and nob3:2020). Finally print the information of the object that has smallest nob2 for these three objects using void display friend function:arrow_forward(Payroll System Modification) Modify the payroll system of Figs. 20.9–20.17 to includeadditional Employee subclasses PieceWorker and HourlyWorker. A PieceWorker represents an employee whose pay is based on the number of pieces of merchandise produced. An HourlyWorker represents an employee whose pay is based on an hourly wage and the number of hours worked. Hourlyworkers receive overtime pay (1.5 times the hourly wage) for all hours worked in excess of 40 hours.Class PieceWorker should contain private instance variables wage (to store the employee’swage per piece) and pieces (to store the number of pieces produced). Class HourlyWorker shouldcontain private instance variables wage (to store the employee’s wage per hour) and hours (to storethe hours worked). In class PieceWorker, provide a concrete implementation of method earningsthat calculates the employee’s earnings by multiplying the number of pieces produced by the wageper piece. In class HourlyWorker, provide a concrete…arrow_forwardQ2) Write C++ code to create class called number. The private data members for this class are nobl (double), nob2 (double) and nob3(double). The member function for this class is: 1- (Constructor) that accepts nob1, nob2 and nob3 as arguments (inside the class). Write a main() that create two objects (hl) with initially data members (nobl :13000, nob2:15 and nob3 :19), (kl) with initially data members (nobl:16000, nob2:77 and nob3:2018) and (TI) with initially data members (nobl:15000, nob2:37 and nob3:2020). Finally print the information of the object that has smallest nob2 for these three objects using void display friend function:arrow_forward
- Pythonarrow_forwardProblem 3 (Comparing Student Data)Write a method called compare_average() that takes a student object as a parameter.This method must compare the average grades of the calling object with that of theparameter object and print the results. It does not return anything.See the sample output below. Alice has a higher average than BobBob has a higher average than CathyAlice has a higher average than Cathyarrow_forwardc++ ()Write a class called Shapes that includes overloaded functions for the following shapes: c++ Square Triangle Circle For each Shape, include the following functions: area circumference vertices print update For each function, determine what parameters of what types it needs to accept and what it needs to return. Hint: area and circumference parameters and return value should NOT be int. Of course, also determine what attributes you need to define in the class. For each Shape, include the following operators: + * = Each of these operators should take in the same class type(s) and return (also) the same type as indicated by the operator. For example, for + with a triangle, add each of the attributes in order to return the new triangle. Make sure that each of these classes has the canonical constructors and assignment operators (ie, copy and move).arrow_forward
- (CLO3) Read the following description and answer the following questions about it: Problem Description: A car dealership allows customer to purchase their new cars with different options. At this time, those options are color, model, and air condition, as shown below in class CustomerOrder. Of course, the dealership wants the software to be flexible enough to be able to add more options in the future, if needed. CustomerOrder -carColor: String -carModel: String -hasAirCondition: boolean Q1) Write the full required code in Java to use the Builder design pattern to create class CustomerOrder. Q2) Write a Java main() method to create an object of class CustomerOrder with color "red" and without air condition.arrow_forwardstate the statement either true or false.arrow_forwardResearch assistants provide support to professionals who are conducting experiments or gathering andanalyzing information and data. Suppose you are working as RA (research assistant) with a Professor who isworking on a project and evaluating complex mathematical equations. Your duty is to assist him, so in thisregard he has assigned a task to you. Your task is to write a oop c++ program to create a class named equation which will have the data members a, b and c which are the coefficients of the quadratic equation. The class will have two more data members namely proot and nroot which stand for the positive root and negative root of the equation. Suppose that variables a, b and c are integers. Where proot and nroot are floats. Input Function to get values of a, b and c Then design a friend function which will determine the proot and nroot of the equation. Create another friend function which will display the values of proot and nroot.arrow_forward
- (The Fan class) Design a class named Fan to represent a fan. The class contains:■ Three constants named SLOW, MEDIUM, and FAST with the values 1, 2, and 3 to denotethe fan speed.■ A private int data field named speed that specifies the speed of the fan (the default isSLOW).■ A private boolean data field named on that specifies whether the fan is on (the default is false) ■ A private double data field named radius thatspecifiesthe radius of the fan (the default is5).■ A string data field named color thatspecifiesthe color of the fan (the default is blue).■ The accessor and mutator methodsfor all four data fields.■ A no-arg constructorthat creates a default fan.■ A method named toString() that returns a string description for the fan. If the fan is on, the method returns the fan speed, color, and radius in one combined string. If the fan is not on, the method returns the fan color and radius along with the string “fan is off” in onecombined string.Draw the UML diagram for the class and…arrow_forwardC++ : Defining class Person, class Student, class Teacher and class Graduate. Note that class Student and class Teacher inherits from Person, and class Graduate inherits from Student. Defining two constructors (including a default constructor) for each class. Defining virtual function print() for three classes (person, teacher and graduate), where each has different function body. Writing a main function to test the above definition and run each print function.arrow_forwardC++ (Tic-Tac-Toe) Write a program that allows two players to play the tic- tac-toe game. Your program must contain the class ticTacToe to implement a ticTacToe objectarrow_forward
- 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