C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 12, Problem 2PP
(General math) a. Construct a class named Cartesian containing two double-precision data members named x and y, which will be used to store the x and y values of a point in rectangular coordinates. The member functions should include a constructor that initializes an object’s x and y values to 0 and functions to input and display an object’s x and y values. Additionally, include an assignment function that performs a memberwise assignment between two Cartesian objects.
b. Include the class written for Exercise 2a in a working C++
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
USE 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…
(Polymorphic Banking Program Using Account Hierarchy) Develop a polymorphic banking program using the Account hierarchy created in Exercise 19.10. Create a vector of Accountpointers to SavingsAccount and CheckingAccount objects. For each Account in the vector, allowthe user to specify an amount of money to withdraw from the Account using member function debit and an amount of money to deposit into the Account using member function credit. As youprocess each Account, determine its type. If an Account is a SavingsAccount, calculate the amountof interest owed to the Account using member function calculateInterest, then add the interestto the account balance using member function credit. After processing an Account, print the updated account balance obtained by invoking base-class member function getBalance.
(Rectangle Class) Create a class Rectangle with attributes length and width, each of whichdefaults to 1. Provide member functions that calculate the perimeter and the area of the rectangle.Also, provide set and get functions for the length and width attributes. The set functions should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0.
Chapter 12 Solutions
C++ for Engineers and Scientists
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
- (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(Dynamic Binding vs. Static Binding) Distinguish between static binding and dynamicbinding. Explain the use of virtual functions and the vtable in dynamic bindingarrow_forward(Polymorphic Application) You’ve been asked to develop a flight simulator that will haveelaborate graphical outputs. Explain why polymorphic programming could be especially effectivefor a problem of this nature.arrow_forward
- (VISUAL DOT NET) ANSWER B,C, D PARTSarrow_forward(JAVA) This work must use object orientation, inheritance, and java collections, such as HashTable and Lists. The program to be developed must allow the registration of all the subjects of the course, as well as their prerequisites, and recommended sequence. Allow a student to be registered and then, as the student completes courses, inform the recommended sequence of courses. Functionalities: Register subjects, prerequisites (other subjects), areas (software engineering, machine learning, ...) and type (basic, elective group 1, elective group 2), and schedule Register recommended sequence It is suggested for the two cases above that the registration is in the code to avoid rework Allow student registration (name, area of interest: software engineering, machine learning, ...) Allow the student to report the course taken, with a grade Evaluate subjects taken by the student and inform which ones could be taken in the following semester, setting up a schedule for the same Allow…arrow_forward(Abstract Base Classes) Suggest one or more levels of abstract base classes for the Shape hierarchy discussed in this chapter and shown in Fig. 19.3. (The first level is Shape, and the secondlevel consists of the classes TwoDimensionalShape and ThreeDimensionalShape.)arrow_forward
- (Hand Written Submission) Question # 1 a) What is the difference between an interface, class and an instance of the class?b) Is it a good idea to make member variables private? Why or why not?c) What is a constructor? Is it possible to have more than one constructor?d) What is the difference between static data member and an instance data member?e) What is the difference between composition and aggregation? Question # 2 Write a program to model the kinds of people one finds in a university. The categories are students,teachers and teaching assistant (TAs). All these categories are kinds of Person (Person is abstract class. Ateaching assistant (TA) is a student and a teacher as well.A person has a name (string). A student has grade point average GPA (between 0 to 4), the teacher hasthe number of scholarly papers he/she has published and the teacher assistant has the number of courseshe/she assists.All the classes contain constructors with default arguments to fill all data…arrow_forward(C++) A class of points to be implemented for a two dimensional planeyou must write. This class should contain the following content: a. Subfields: x and y coordinate information.b. Default constructor: zero values to x and y valuesshould assign.c. The configurator that assigns a value: It must initialize by taking external parameters to x and y values.D. Duplicate constructor: Must create a copy by reference to another point type object.to. Getter and setter methods: Must be written for x and y subfields.f. differenceDone (Point other) method: This method should return the Euclidean distance between the point object and the "other" point object.g. The toString () method: It should return the point structured as a string.arrow_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
- (Python) (The Stock class) Design a class named Stock to represent a company’s stock that contains: A private string data field named symbol for the stock’s symbol. A private string data field named name for the stock’s name. A private float data field named previousClosingPrice that stores the stock price for the previous day. A private float data field named currentPrice that stores the stock price for the current time. A constructor that creates a stock with the specified symbol, name, previous price, and current price. A get method for returning the stock name. A get method for returning the stock symbol. Getandsetmethodsforgetting/settingthestock’spreviousprice. Getandsetmethodsforgetting/settingthestock’scurrentprice. A method named getChangePercent() that returns the percentage changed from previousClosingPrice to currentPrice. Draw the UML diagram for the class, and then implement the class. Write a test program that creates a Stock object with the stock…arrow_forward(C++) Create a class Cylinder with attributes base-radius and height, each of which defaults to 1 .Provide member functions that calculate the surface area ( = 2πrh) and the volume (= πr2h) of the cylinder. Also, provide set and get functions for the base radius and height attributes. The set functions should verify that base radius and height are each floating- point numbers larger than 0.0 and less than 20.0. Use M PI from < cmath > header for π.arrow_forwardQ2) Write a C++ program, which contains the class RealNumbers that should be defined as illustrated in the following class diagram. This class contains two data members of type double: fNo and sNo: and the following member functions: default constructor, setters for the two data members, computeSum () to compute and return the summation result of the two data members and computeMult () to compute and print the multiplication result of the two data members. In the ma in function, implement the following processes: Create the object no from the class Real Numbers. • Set the values 4.4, 7.5) to the data RealNumbers - fNo: double - SNo: double +default constructor members for the object no. • Display the summation result of the two data members for the object no. • Display the multiplication result of the two data members for the object no. +setters for the two data members +computeSum(): double +computeMult(): voidarrow_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
functions in c programming | categories of function |; Author: Education 4U;https://www.youtube.com/watch?v=puIK6kHcuqA;License: Standard YouTube License, CC-BY