Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need this program ASAP C++ language 1b. Write the implementation file timeClock.

ID: 3803474 • Letter: N

Question

Need this program ASAP

C++ language

1b. Write the implementation file timeClock.cpp for the class TimeClock. Com pile the file, and save it in the Chap 13 folder of your Student Data Files. 1c. Write a C++ program named weeklyPay.cpp to test your class Timeclock Your program should ask the user how many hours the user worked each day of the week. An object should be created for each day of the week with the number of hours for each day worked and an object for the weekly total. Save your program as weekly Pay.cpp and execute it The following is a copy of the screen results that might appear after running your program, depending on the data entered. The input entered by the user is shown in bold. This program asks the user for the number of hours worked each day of the week, totals the hours, and shows the days and hours worked How many hours did you work Monday 4 How many hours did you work Tuesday 9 How many hours did you work Wednesday? 3 How many hours did you work Thursday 12 How many hours did you work Friday 3 How many hours did you work Saturday? 7 How many hours did you work Sunday? 0 This week you worked in days in Hc Monday Tuesday 1. 125 Wednesday 0.375 1.5 Thursday 12 Friday 0.375 Saturday 0.875 Sunday Total for the week 4.75 38

Explanation / Answer

//main.cpp

#include"Mar_timeClass.h"
#include<string>
#include<iomanip>
int main()
{
   //declare object for 7 days
   Timeclock week[7];
   float hours;
   string days[7] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };

   for (int i = 0; i < 7; i++)
   {
       cout << "How many hours did you work " << days[i] << "? ";
       cin >> hours;
       week[i].setDays(hours);
       week[i].setHours(hours);
   }
   //display results
   cout << "This week you worked in days:       hours" << endl;
   float total = 0,hr = 0;
   for (int i = 0; i < 7; i++)
   {
       cout << setw(10)<<days[i]<<" ";
       week[i].display();
       total += week[i].getDays();
       hr += week[i].getHours();
   }
   cout << "Total for the week : " << setprecision(3) << total << " " << (int)hr << endl;
}

----------------------------------------------------

//.h file Mar_timeClass.h

#ifndef TIMECLOCK_H
#define TIMECLOCK_H
#include<iostream>
using namespace std;

class Timeclock
{
   float days;
   float hours;
public:
   Timeclock(float d = 0, float h = 0);
   float getDays();
   void setDays(float h);
   float getHours();
   void setHours(float h);
   Timeclock operator+(float h);
   Timeclock operator-(float h);
   void display();
};
#endif

-----------------------------------------

//.Timeclass implementation file ie Mar_timeClass.cpp

#include"Mar_timeClass.h"
#include<iomanip>

Timeclock::Timeclock(float d, float h) :days(0), hours(0)
{

}

float Timeclock::getDays()
{
   return days;
}
void Timeclock::setDays(float h)
{
   //devide hours by 8 to get days as 8 is the working hours for one day
   days = (float)h / 8;
}
float Timeclock::getHours()
{
   return hours;
}
void Timeclock::setHours(float h)
{
   hours = h;
}
Timeclock Timeclock::operator+ (float h)
{
   Timeclock tmp;
   float d, h1;
   d = days + (float)h / 8;
   h1 = hours + h;
   tmp.setDays(d);
   tmp.setHours(h1);
   return tmp;
}
Timeclock Timeclock::operator- (float h)
{
   Timeclock tmp;
   float d, h1;
   d = days - (float)h / 8;
   h1 = hours - h;
   tmp.setDays(d);
   tmp.setHours(h1);
   return tmp;
}
void Timeclock::display()
{
   cout << fixed;
   cout << setw(5) << setprecision(3)<<days << setw(3) << " "<<(int)hours << endl;
   //cout << days << setw(5) << days << " " << setw(2)<<(int)hours << endl;
}

-----------------------------------------------------

//output

How many hours did you work Monday? 4
How many hours did you work Tuesday? 9
How many hours did you work Wednesday? 3
How many hours did you work Thursday? 12
How many hours did you work Friday? 3
How many hours did you work Saturday? 7
How many hours did you work Sunday? 0
This week you worked in days: hours
Monday 0.500 4
Tuesday 1.125 9
Wednesday 0.375 3
Thursday 1.500 12
Friday 0.375 3
Saturday 0.875 7
Sunday 0.000 0
Total for the week : 4.750 38

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote