Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include using namespace std; class TimeCard { public: TimeCard(double workingHours = 0.0, double vacationHours = 0.0); void Print() const; TimeCard operator-(double rhs); TimeCard operator-(TimeCard rhs);

image text in transcribed

#include using namespace std;

class TimeCard { public: TimeCard(double workingHours = 0.0, double vacationHours = 0.0); void Print() const; TimeCard operator-(double rhs); TimeCard operator-(TimeCard rhs); private: double hoursWorked; double hoursOff; };

TimeCard::TimeCard(double workingHours, double vacationHours) { hoursWorked = workingHours; hoursOff = vacationHours; }

// No need to accommodate for overflow or negative values

/* Your code goes here */

void TimeCard::Print() const { cout

int main() { double workingHours1; double vacationHours1; double workingHours2; double vacationHours2; cin >> workingHours1; cin >> vacationHours1; cin >> workingHours2; cin >> vacationHours2; TimeCard timeCard1(workingHours1, vacationHours1); TimeCard timeCard2(workingHours2, vacationHours2); TimeCard difference1 = timeCard1 - workingHours2; TimeCard difference2 = timeCard1 - timeCard2; timeCard1.Print(); cout 450928.2561122.qx3zqy7 Jump to level 1 Four doubles are read from input, where the first two doubles are the hours worked and hours off of timeCard1 and the second two doubles are the hours worked and hours off of timeCard2. Define two functions to overload the - operator. The first function overloads the - operator to subtract a time card and a double representing the number of hours worked. The second function overloads the - operator to subtract two time cards. Ex: If the input is 10.010.08.08.0, then the output is: 10 hours worked, 10 hours off 8 hours worked Difference: 2 hours worked, 10 hours off 10 hours worked, 10 hours off 8 hours worked, 8 hours off Difference: 2 hours worked, 2 hours off Note: The difference of a time card and a double representing the number of hours worked is: - the difference of the number of hours worked and the double - the number of hours off is unchanged Note: The difference of two time cards is: - the difference of the number of hours worked - the difference of the number of hours off 1 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2008 Comprehensive Concepts And Techniques

Authors: Gary B. Shelly, Corinne Hoisington

1st Edition

1423927168, 978-1423927167

More Books

Students also viewed these Databases questions