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
Thermodynamics: An Engineering Approach
SURVEY OF OPERATING SYSTEMS
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Mechanics of Materials (10th Edition)
Fluid Mechanics: Fundamentals and Applications
Java: An Introduction to Problem Solving and Programming (8th Edition)
- 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 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_forwardQ1: A- Choose the correct answer. 1. A function's single most important role is to: a. reduce program size. c. accept arguments and return value. 2. In a class definition, private data or functions are accessible: a. to any function in the program. c. to member functions of that class. 3. A member function can always access the data: a. in the object of which it is a member. c. in any object of the class of which it is a member. 15 marks| b. give a name to a block of code. d. organize a program into conceptual units. b. only if you know the password. d. only to public members of the class. b. in the class of which it is a member. d. in the public part of its class.arrow_forwardWhen an object is passed to a function, a copy of it is made if the object is A) passed by valueB) passed by referenceC) passed by constant referenceD) any of the abovearrow_forward
- c++ ()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_forwardDefine the term void functions.arrow_forwardQ2) Write a C# class Factors having function static int CountOddFactors(int n) that would return count of odd factors of parameter n. For instance, odd factors of 20 are: 1 and 5, and odd factors of 30 are 1, 3, 5 and 15. Call this static function in main function that is in another class. SUBJECT:CSHARP(VISUAL PROGRAMMING)arrow_forward
- 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 (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_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
- C++ : 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_forwardWrite 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.arrow_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