MyProgrammingLab - For Gaddis: Starting Out with C++ From Control Structures through Objects
MyProgrammingLab - For Gaddis: Starting Out with C++ From Control Structures through Objects
15th Edition
ISBN: 9780133780611
Author: Pearson
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 14, Problem 5PC
Program Plan Intro

Time Off

Program plan:

source.cpp

  • Include the required header files to the program.
  • Define the “main()” function.
    • Create an object for the “TimeOff” class and pass an input value to the function.
    • Retrieving the outputs from the “TimeOff” class and print it.

TimeOff.cpp

  • Include the required header files to the program.
  • Define the default constructor for the “TimeOff” class.
    • Set the name, if the string is not an empty.
    • Set the employee ID.
    • Set the maximum sick days and days of sick leave taken by an employee.
    • Check the max vacation hours is greater than 240.
      • If so, set the max vacation as 240.
    • Otherwise, set the max vacation as given hours.
    • Set the max unpaid leave, unpaid leave hours and vacation taken by an employee.

TimeOff.h

  • Include the required header files to the program.
  • In private, declare the required variables.
  • In public, create the constructor.
  • Create a mutator functions and accessor functions for setting and returning the value.

NumDays.cpp

  • Include the required header files to the program.
  • The function definition of overloaded binary “+” operator.
    • Create an object for the “NumDays” class.
    • Add the objects.
    • Return the object to the function.
  • The function definition of overloaded binary “-” operator.
    • Create an object for the “NumDays” class.
    • Subtract the objects.
    • Return the object to the function.
  • The function definition of overloaded prefix “++” operator.
    • Increment the hours.
    • Calculate the days by dividing hours by 8.
    • Return the object to the function.
  • The function definition of overloaded postfix “++” operator.
    • Create an object for the “NumDays” class.
    • Increment the hours.
    • Calculate the days by dividing hours by 8.
    • Return the object to the function.
  • The function definition of overloaded prefix “--” operator.
    • Decrement the hours.
    • Calculate the days by dividing hours by 8.
    • Return the object to the function.
  • The function definition of overloaded postfix “--” operator.
    • Create an object for the “NumDays” class.
    • Decrement the hours.
    • Calculate the days by dividing hours by 8.
    • Return the object to the function.

NumDays.h

  • Include the required header files to the program.
  • In private, declare the required variables.
  • In public, create the constructor.
    • Set the days and hours.
  • Create a mutator and accessor function for the days and hours.
  • Call the required overloaded operator functions.

Blurred answer
Students have asked these similar questions
Create a class called time. The time class has three private data members of type int, named hours, minutes and seconds. • Provide a no‐argument constructor for the class which initializes the data members to 0. • Provide another constructor which sets the data members to the values passed from the main. It should also validate whether the values are correct i.e., hours should be between 0 and 23 (inclusive), minutes should be between 0 and 60 (inclusive) and seconds should also be between 0 and 60 (inclusive). If an invalid value is entered, the constructor should automatically change it to 0. • Write a function getTime() which asks the user to input the values for hours, minutes and seconds. While taking the input values, it must also validate the input values as in the above case. • Write a function displayTime() which displays the time in the format 11:39:45 i.e. hours:minutes:seconds. • Write a function totaltime () that adds two objects of type Time passed as…
Create a class called Account that a bank might use to represent customers' bank accounts. Your class should include one data member as int accountNumber and other of type float to represent the account balance.  Your class should provide a default and parameterized constructor that receives an initial balance and accountNumber and uses it to initialize the data members.   The constructor should validate the initial balance to ensure that it is greater than or equal to 0. If not, the balance should be set to 0 and the constructor should display an error message, indicating that the initial balance was invalid. The class should provide getter/setters for data members. The class should provide three member functions.   Member function credit (float amount, int accountNumber) should add an amount to the current balance. Member function debit (float amount, int accountNumber) should withdraw money from the Account and should ensure that the debit amount does not exceed the Account's…
Create a class called Account that a bank might use to represent customers' bank accounts. Your class should include one data member as int accountNumber and other of type float to represent the account balance.  Your class should provide a default and parameterized constructor that receives an initial balance and accountNumber and uses it to initialize the data members.   The constructor should validate the initial balance to ensure that it is greater than or equal to 0. If not, the balance should be set to 0 and the constructor should display an error message, indicating that the initial balance was invalid. The class should provide getter/setters for data members. The class should provide three member functions.   Member function credit (float amount, int accountNumber) should add an amount to the current balance. Member function debit (float amount, int accountNumber) should withdraw money from the Account and should ensure that the debit amount does not exceed the Account's…

Chapter 14 Solutions

MyProgrammingLab - For Gaddis: Starting Out with C++ From Control Structures through Objects

Ch. 14.4 - When is a copy constructor called?Ch. 14.4 - How does the compiler know that a member function...Ch. 14.4 - What action is performed by a classs default copy...Ch. 14.5 - Assume there is a class named Pet. Write the...Ch. 14.5 - Assume dog and cat are instances of the Pet class,...Ch. 14.5 - What is the disadvantage of an overloaded =...Ch. 14.5 - Prob. 14.17CPCh. 14.5 - The this pointer is automatically passed to what...Ch. 14.5 - Assume there is a class named Animal that...Ch. 14.5 - Prob. 14.20CPCh. 14.5 - Describe the values that should be returned from...Ch. 14.5 - Prob. 14.22CPCh. 14.5 - What type of object should an overloaded operator...Ch. 14.5 - What type of object should an overloaded operator...Ch. 14.5 - If an overloaded or operator accesses a private...Ch. 14.5 - Prob. 14.26CPCh. 14.6 - When overloading a binary operator such as + or ...Ch. 14.6 - Explain why overloaded prefix and postfix ++ and ...Ch. 14.6 - Prob. 14.29CPCh. 14.6 - Write member functions of the FeetInches class...Ch. 14.8 - What are the benefits of having operator functions...Ch. 14.8 - Prob. 14.32CPCh. 14.8 - Assume there is a class named BlackBox. Write the...Ch. 14.8 - Assume there are two classes, Big and Small. The...Ch. 14 - Describe the difference between an instance member...Ch. 14 - Assume a class named Numbers has the following...Ch. 14 - A static member variable is declared in a class....Ch. 14 - Prob. 4RQECh. 14 - Why is it not always a good idea to make an entire...Ch. 14 - What is memberwise assignment?Ch. 14 - When is a copy constructor called?Ch. 14 - How can the compiler determine if a constructor is...Ch. 14 - Describe a situation where memberwise assignment...Ch. 14 - Why must the parameter of a copy constructor be a...Ch. 14 - What is a default copy constructor?Ch. 14 - Why would a programmer want to overload operators...Ch. 14 - What is passed to the parameter of a classs...Ch. 14 - Why shouldnt a classs overloaded = operator be...Ch. 14 - How does the compiler know whether an overloaded...Ch. 14 - Prob. 16RQECh. 14 - What type of value should be returned from an...Ch. 14 - The class Stuff has both a copy constructor and an...Ch. 14 - Explain the programming steps necessary to make a...Ch. 14 - Explain the programming steps necessary to make a...Ch. 14 - Consider the following class declaration: class...Ch. 14 - Describe the difference between making a class a...Ch. 14 - What is the purpose of a forward declaration of a...Ch. 14 - Explain why memberwise assignment can cause...Ch. 14 - Why is a classs copy constructor called when an...Ch. 14 - If a member variable is declared ______________,...Ch. 14 - Static member variables are defined __________ the...Ch. 14 - A(n) __________ member function cannot access any...Ch. 14 - A static member function may be called __________...Ch. 14 - A(n) __________ function is not a member of a...Ch. 14 - A(n) _________ tells the compiler that a specific...Ch. 14 - Prob. 32RQECh. 14 - A(n) _________ is a special constructor, called...Ch. 14 - is aspecial built-in pointer that is automatically...Ch. 14 - An operator may beto work with a specific class.Ch. 14 - When overloading the ________ operator, its...Ch. 14 - Making an instance of one class a member of...Ch. 14 - Object aggregation is useful for creating a(n)...Ch. 14 - Assume a class named Bird exists. Write the header...Ch. 14 - Assume a class named Dollars exists. Write the...Ch. 14 - Assume a class named Yen exists. Write the header...Ch. 14 - Assume n class named Length exists. Write the...Ch. 14 - Assume a class named Collection exists. Write the...Ch. 14 - T F Static member variables cannot be accessed by...Ch. 14 - T F Static member variables are defined outside...Ch. 14 - T F A static member function may refer to...Ch. 14 - T F When a function is declared a friend by a...Ch. 14 - T F A friend function has access to the private...Ch. 14 - T F An entire class may be declared a friend of...Ch. 14 - T F In order for a function or class to become a...Ch. 14 - T F If a class has a pointer as a member, its a...Ch. 14 - T F You cannot use the = operator to assign one...Ch. 14 - T F If a class doesnt have a copy constructor, the...Ch. 14 - T F If a class has a copy constructor, and an...Ch. 14 - T F The this pointer is passed to static member...Ch. 14 - T F All functions that overload unary operators...Ch. 14 - T F For an object to perform automatic type...Ch. 14 - T F It is possible to have an instance of one...Ch. 14 - class Box { private: double width; double length;...Ch. 14 - class Circle { private: double diameter; int...Ch. 14 - class Point { private: int xCoord; int yCoord;...Ch. 14 - class Box { private: double width; double length:...Ch. 14 - class Yard { private: float length; public:...Ch. 14 - Prob. 1PCCh. 14 - Day of the Year Assuming a year has 365 days,...Ch. 14 - Day of the Year Modification Modify the DayOfYear...Ch. 14 - NumDays Class Design a class called NumDays. The...Ch. 14 - Prob. 5PCCh. 14 - Personnel Report NOTE: This assignment assumes you...Ch. 14 - Month Class Design a class named Month. The class...Ch. 14 - Date Class Modification Modify the Date class in...Ch. 14 - Feetlnches Modification Modify the Feetlnches...Ch. 14 - Corporate Sales A corporation has six divisions,...Ch. 14 - FeetInches Class Copy Constructor and multiply...Ch. 14 - LandTract Class Make a LandTract class that is...Ch. 14 - Carpet Calculator The Westfield Carpet Company has...Ch. 14 - Parking Ticket Simulator For this assignment, you...Ch. 14 - Car Instrument Simulator For this assignment you...
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,