STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 7.10, Problem 7.22CP
Write a class declaration for a class named Pizza that has the data members price, a double, and size, a Circle object (declared in question 7.21). It also has member functions: setPrice, setSize, and costPerSqIn. Write the code for these as mime functions.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create a class called Employee that includes three pieces of information as data members—a first name (type string), a last name (type string) and a monthly salary (type int). Your class should have a constructor that initializes the three data members. Provide a set and a get function for each data member. If the monthly salary is not positive, set it to 0. Write a test program that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10 percent raise and display each Employee’s yearly salary again.
Write a class named Patient that has member variables for first name, middle name, last name, phone number, name and phone number of emergency contact. The Patient class should have a constructor that accepts and argument for each member variable. The Patient class should also have accessor and mutator functions for each member variable.
Write a class named Procedure that has member variables for name of procedure, date of procedure, name of physician, and charges for the procedure. This Procedure class represents a medical procedure that is performed on a patient. The Procedure class should have a constructor that accepts an argument for each member variable. The Procedure class should also have accessor and mutator functions for each member variable.
Then write a program that creates an instance of the Patient class initialized with sample data that is entered by the user.
Then, create an instance of the Procedure class for each procedure that is being…
Write a class named Patient that has member variables for first name, middle name, last name, phone number, name and phone number of emergency contact. The Patient class should have a constructor that accepts and argument for each member variable. The Patient class should also have accessor and mutator functions for each member variable. Write a class named Procedure that has member variables for name of procedure, date of procedure, name of physician, and charges for the procedure. This Procedure class represents a medical procedure that is performed on a patient. The Procedure class should have a constructor that accepts an argument for each member variable. The Procedure class should also have accessor and mutator functions for each member variable. Then write a program that creates an instance of the Patient class initialized with sample data that is entered by the user. Then, create an instance of the Procedure class for each procedure that is being performed on the patient. There…
Chapter 7 Solutions
STARTING OUT WITH C++ MPL
Ch. 7.5 - Which of the following shows the correct use of...Ch. 7.5 - An objects private member variables can be...Ch. 7.5 - Assuming that soap is an instance of the Inventory...Ch. 7.5 - Complete the following code skeleton to declare a...Ch. 7.7 - Briefly describe the purpose of a constructor.Ch. 7.7 - Constructor functions have the same name as the A)...Ch. 7.7 - A constructor that requires no arguments is called...Ch. 7.7 - Assume the following is a constructor: ClassAct: :...Ch. 7.7 - Prob. 7.9CPCh. 7.7 - True or false: A class may have a constructor with...
Ch. 7.7 - A destructor function name always starts with A) a...Ch. 7.7 - True or false: Just as a class can have multiple...Ch. 7.7 - What will the following program code display on...Ch. 7.7 - What will the following program code display on...Ch. 7.9 - 7.15 private class member function can be called...Ch. 7.9 - When an object is passed to a function, a copy of...Ch. 7.9 - If a function receives an object as an argument...Ch. 7.9 - Prob. 7.18CPCh. 7.9 - Prob. 7.19CPCh. 7.10 - Prob. 7.20CPCh. 7.10 - Write a class declaration for a class named...Ch. 7.10 - Write a class declaration for a class named Pizza...Ch. 7.10 - Write four lines of code that might appear in a...Ch. 7.11 - Assume the following class components exist in a...Ch. 7.11 - What header files should be included in the client...Ch. 7.12 - Write a structure declaration for a structure...Ch. 7.12 - Prob. 7.27CPCh. 7.12 - Prob. 7.28CPCh. 7.12 - Write a declaration for a structure named...Ch. 7.12 - Write a declaration for a structure named City,...Ch. 7.12 - Write assignment statements that store the...Ch. 7.12 - Prob. 7.32CPCh. 7.12 - Write a function that uses a Rectangle structure...Ch. 7.12 - Prob. 7.34CPCh. 7.15 - Prob. 7.35CPCh. 7.15 - When designing an object -oriented application,...Ch. 7.15 - How do you identify the potential classes in a...Ch. 7.15 - What two questions should you ask to determine a...Ch. 7.15 - Look at the following description of a problem...Ch. 7 - Prob. 1RQECh. 7 - Which of the following must a programmer know...Ch. 7 - Prob. 3RQECh. 7 - ______programming is centered around functions, or...Ch. 7 - An object is a software entity that combines both...Ch. 7 - An object is a(n) ______ of a class.Ch. 7 - Prob. 7RQECh. 7 - Once a class is declared, how many objects can be...Ch. 7 - An objects data items are stored in its...Ch. 7 - The procedures, or functions, an object performs...Ch. 7 - Bundling together an objects data and procedures...Ch. 7 - An objects members can be declared public or...Ch. 7 - Normally a classs _________ are declared to be...Ch. 7 - A class member function that uses, but does not...Ch. 7 - A class member function that changes the value of...Ch. 7 - When a member functions body is written inside a...Ch. 7 - A class constructor is a member function with the...Ch. 7 - A constructor is automatically called when an...Ch. 7 - Constructors cannot have a(n) ______ type.Ch. 7 - A(n) ______ constructor is one that requires no...Ch. 7 - A destructor is a member function that is...Ch. 7 - A destructor has the same name as the class but is...Ch. 7 - A constructor whose parameters all have default...Ch. 7 - A class may have more than one constructor, as...Ch. 7 - Prob. 25RQECh. 7 - In general, it is considered good practice to have...Ch. 7 - When a member (unction forms part of the interface...Ch. 7 - When a member function performs a task internal to...Ch. 7 - True or false: A class object can be passed to a...Ch. 7 - Prob. 30RQECh. 7 - It is considered good programming practice to...Ch. 7 - If you were writing a class declaration for a...Ch. 7 - If you were writing the definitions for the Canine...Ch. 7 - A structure is like a class but normally only...Ch. 7 - By default, are the members of a structure public...Ch. 7 - Prob. 36RQECh. 7 - When a structure variable is created its members...Ch. 7 - Prob. 38RQECh. 7 - Prob. 39RQECh. 7 - Prob. 40RQECh. 7 - Prob. 41RQECh. 7 - Write a function called showReading. It should...Ch. 7 - Write a function called input Reading that has a...Ch. 7 - Write a function called getReading, which returns...Ch. 7 - Indicate whether each of the following enumerated...Ch. 7 - Prob. 46RQECh. 7 - Assume a class named Inventory keeps track of...Ch. 7 - Write a remove member function that accepts an...Ch. 7 - Prob. 49RQECh. 7 - A) struct TwoVals { int a, b; } ; int main() { }...Ch. 7 - A) struct Names { string first; string last; } ;...Ch. 7 - A) class Circle: { private double centerX; double...Ch. 7 - A) class DumbBell; { int weight; public: void set...Ch. 7 - If the items on the following list appeared in a...Ch. 7 - Look at the following description of a problem...Ch. 7 - Soft Skills Working in a team can often help...Ch. 7 - Date Design a class called Date that has integer...Ch. 7 - Report Heading Design a class called Heading that...Ch. 7 - Widget Factory Design a class for a widget...Ch. 7 - Car Class Write a class named Car that has the...Ch. 7 - Population In a population, the birth rate and...Ch. 7 - Gratuity Calculator Design a Tips class that...Ch. 7 - Inventory Class Design an Inventory class that can...Ch. 7 - Movie Data Write a program that uses a structure...Ch. 7 - Movie Profit Modify the Movie Data program written...Ch. 7 - Prob. 10PCCh. 7 - Prob. 11PCCh. 7 - Ups and Downs Write a program that displays the...Ch. 7 - Wrapping Ups and Downs Modify the program you...Ch. 7 - Left and Right Modify the program you wrote for...Ch. 7 - Moving Inchworm Write a program that displays an...Ch. 7 - Coin Toss Simulator Write a class named Coin. The...Ch. 7 - Tossing Coins for a Dollar Create a game program...Ch. 7 - Fishing Came Simulation Write a program that...Ch. 7 - Group Project 19. Patient Fees This program should...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What populates the Smalltalk world?
Concepts Of Programming Languages
Software Sales Software companies often offer their customers the option to lease the software yearly or purcha...
Starting Out With Visual Basic (7th Edition)
Long-Distance Calls A long-distance carrier charges the following rates for telephone calls: Starting Time of C...
Starting Out with C++ from Control Structures to Objects (9th Edition)
What is the bug in the code in the previous question?
Java: An Introduction to Problem Solving and Programming (7th Edition)
Write a loop equivalent to the for loop above without using .
C Programming Language
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
- PROGRAMMING LANGUAGE: C++ Write a program that has a base class named FlightCrew. This class shouldhave three data members: an integer to store the ID of the crew member, aninteger to store the number of years of service and another integer to storethe total salary of the member. Provide a parameterized constructor in theclass to set the values of the data members.Derive a class Pilot from FlightCrew to contain two additional data members,an integer to store the number of hours of flight and a boolean to storewhether the Pilot has military experience or not. Provide a paramete rizedconstructor in the Pilot class. Provide a function bonus() in the class wherethe bonus of a pilot is his number of flight hours times the 10% of his salary.Likewise, provide a function isEligible() in the class to find out if the pilot iseligible for promotion or not. A pilot is eligible for promotion to the nextrank if he has at least 5 years of experience and the number of total flighthours is greater…arrow_forwardRewrite the calculator program using a class called calculator. Your program will keep asking the user if they want to perform more calculations or quit and will have a function displayMenu to display the different functions e.g .(1 - addition, 2- subtraction, 3- multiplication, 4- division) Your program must have appropriate constructors and member functions to initialize, access, and manipulate the data members as well as : A member function to perform the addition and return the result A member function to perform the subtraction and return the result A member function to perform the multiplication and return the result A member function to perform the division and return the resultarrow_forwardQuestion 8 Write a class called myclass. This class has two data members, a and b. The values of these data members are initially set through arguments passed to the constructor function of the class. Write getter and setter functions for the class with the names get_a, get_b and set_a, set_b, where the setter functions must take a value (the new value for the data member). Write the class to have two functions, one called sum that returns the sum of a and b, and one called difference that returns the difference between a and b (i.e. a - b).arrow_forward
- Create a class named Employee which contains an employee name, available to the entire program (public), and an employee ID number and hourly pay rate, available only to the members of the Employee class (private). Also write a constructor (the __init__ member function) which accepts a pay rate and changes it to 7.25, if the value entered is less than that. Do not write any accessor or mutator methods for the class.arrow_forwardWrite a class named as vehicle which has some attributes this class has three functions.i.e.fuelAmount ()loadingCapacity()applyBrakes()enginePower()Write a class named as Bus, Car and Truck which are inherited from class Vehicle. Also write the setter/getter, default and parameterized constructor in each class. Write a main which create object of derived class and call all inherited function of base class.Note: Each class should have at least two attribute of base class.arrow_forwardWrite a class declaration for a class named Circle, which has the data member radius, a double, and member functions setRadius and getArea. Write the code for these as inline functions.arrow_forward
- In c++, define a class for a type called Counter . An object of this type is used to count things. Include a default constructor that sets the counter to zero and a constructor with one argument that sets the counter to the valuespecified by its argument. Write member functions to increase the value by one (called increment ) and decreasethe value by one (called decrement ), don’t let the value go below 0. Write a member function ( print ) that printsout the value of the counter.Here’s a driver program that you should include to test your class.arrow_forwardConsider a class named Graduate Course that includes Three data members i.e. o courselD (e.g. CS2133), o courseName (e.g. OOP), O creditHours (e.g. 3 or 4), and o courseFee (e.g. Rs. 10,000). A parameterized constructor to initialize data members with values specified by the user Derive a class named Research Course from Course class, which contains An additional data field named experiment Fee A parameterized constructor to initialize its own data member along with data members of the base class inherited in derived class Research Course class also contains a member function named setExperiment Fee to modify the value of its own data field A function named display to show the values of its own attribute along with the attributes of its base class A function named totalFee to display the value of aggregated fee (course fee+ experiment fee) for a particular course object Implement both classes and in the main() function, create an instance of ResearchCourse class. Invoke…arrow_forwardIn Chapter 10, the class clockType was designed to implement the time of day in a program. Certain applications, in addition to hours, minutes, and seconds, might require you to store the time zone. Derive the class extclockType from the class clockType by adding a member variable to store the time zone. Add the necessary member functions and constructors to make the class functional. Also, write the definitions of the member functions and the constructors. Finally, write a test program to test your class.arrow_forward
- In C++, Create a class called Date that includes three data members: amonth(type int), a day(type int), and a year(type int). The Date class willhave a constructor with three parameters to initialize the three data members.You may assume the values provided for the year and day are correct, but makesure that the month value is in the range 1-12; if it isn't, set the month to1. Provide set and get functions for each data member. Provide a memberfunction displayDate that displays the date in format MM/DD/YYYY.Write a test program that prompts the user to input the month, the day,and the year and uses your Date class to output the formatted date.arrow_forwardAssigrment Question: Create a Circle class with a centre (x, y) and radius r. Use parameterized constructor to initialize the radius and centre of a circle object. Write a copy constructor that copies the values of one circle object to another one. Use a member function to display the values x, y, r of a circle object. Allow a friend function to update the centre and radius of the circle. There should a static variable 'number_of_circles' and a static member function 'update_number_of_circles' which will update the 'umber_of_circles' whenever an instance of a circle is created.arrow_forwarda) Create an enumeration named Departments that contain four sets of values FINANCE, HR, IT, and MARKETING.b) Create a class named PersonDetails that contains fields for a person’s first name (String), last name (String), and address (String). The class haveA constructor that accepts parameters for each field and Get methods for each field.c) Create a class named Employee that contains fields for an employee ID (int), Social Security number (String), personal information (Person object), department (Departments type), and annual salary (double). The class haveA constructor that requires values for each data field.Get methods for each of the data fields.Set methods for each of the data fields.d) Create an application/class named EmployeeSort that allows a user to enter values for an array of 5 Employee objects (create an array of Employee type that will save 5 employee objects). Prompt a user for the data needed to create an employee object. Continue to 2prompt the user for Social…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 LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Call By Value & Call By Reference in C; Author: Neso Academy;https://www.youtube.com/watch?v=HEiPxjVR8CU;License: Standard YouTube License, CC-BY