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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//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]<<"\t\t";
       week[i].display();
       total += week[i].getDays();
       hr += week[i].getHours();
   }
   cout << "Total for the week : " << setprecision(3) << total << " \t\t" << (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) << "\t\t"<<(int)hours << endl;
   //cout << days << setw(5) << days << "\t" << 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

Add a comment
Know the answer?
Add Answer to:
Need this program ASAP C++ language 1b. Write the implementation file timeClock.cpp for the class TimeClock....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PYTHON CODE First Code: Write a program that uses a text file to store the daysand...

    PYTHON CODE First Code: Write a program that uses a text file to store the daysand hours that a user worked in a week. The program should begin by prompting for the number of days worked in the week. It should continue with a loop for input of the days and hours and for writing these to the file, each on its own line. Sample Output (inputs shown in boldface) How many days did you work this week? 5 Enter...

  • I need to write a program in java using two array lists. I need to program...

    I need to write a program in java using two array lists. I need to program to prompt the user to enter a day of the week and return an output of a predetermined temperature for the day they selected. I also need the program the output the average of daily temperatures across the week if the user inputs "week". So basically if i set the temperatures to something arbitrary i.e.: Monday = 50 Tuesday = 55 Wednesday = 52...

  • Your professor is hoping to get a summer job flipping burgers at the local burger joint....

    Your professor is hoping to get a summer job flipping burgers at the local burger joint. His starting salary will be $7.25 per hour. However, there are certain incentives to encourage him to work extra hours. It is calculated as follows per day: •$7.25 for the first 6 hours he works per day, Monday through Friday .•$8.25 for the next 2 hours he works per day, Monday through Friday. •$11.25 for each hour he works over 8 hours in a...

  • Coding in C++ Write a program using structures to store the following weather information: - Month...

    Coding in C++ Write a program using structures to store the following weather information: - Month name - Day of month (Monday, Tuesday, etc) - High Temperature - Low Temperature - Rainfall for the day Use an the input.txt file to load the data into weather structures. Once the data for all the days is entered, the program should calculate and display the: - Total rainfall for the data - Average daily temperatures. (note: you'll need to calculate the days...

  • Write a C++ Program. You have a following class as a header file (dayType.h) and main()....

    Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public:     static string weekDays[7];     void print() const;     string nextDay() const;     string prevDay() const;     void addDay(int nDays);     void setDay(string d);     string getDay() const;     dayType();     dayType(string d); private:     string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...

  • Thornton Cinemas is considering a contract to rent a movie for $1,500 per day. The contract...

    Thornton Cinemas is considering a contract to rent a movie for $1,500 per day. The contract requires a minimum one-week rental period. Estimated attendance is as follows: Monday 430 Tuesday 270 Wednesday 200 Thursday 590 1 Friday ,030 Saturday 1,030 Sunday 470 8 02:05:45 Required Skipped a. Determine the average cost per person of the movie rental contract separately for each day. b. Suppose that Thornton chooses to price movie tickets at cost as computed in Requirement a plus $2.00....

  • So, the brewery selected it’s place and now needs to hire folks. After some testing, they...

    So, the brewery selected it’s place and now needs to hire folks. After some testing, they expect to have approximately 2,000 customers per week. Since they will be open 7 days a week, they need to hire people to help serve their beer. They know that Friday and Saturday will drive sales. Between these 2 days, they will get 50% of their weekly sales. So, Friday has 25% of sales and Saturday has 25% of the sales. As for Sunday...

  • THIS CODE SHOULD BE MODIFIED TO READ SuperMarket.dat instead of Inputting and Outputting. SuperMarket.dat Monday 4...

    THIS CODE SHOULD BE MODIFIED TO READ SuperMarket.dat instead of Inputting and Outputting. SuperMarket.dat Monday 4 Monday 6 Monday 2 Tuesday 3 Tuesday 2 Wednesday 3 Wednesday 5 Wednesday 7 Thursday 5 Friday 4 Friday 3 Friday 4 Saturday 8 Saturday 8 Saturday 8 Sunday 0 QUESTION: Write the control break code, including the code for the dayChange() method, in the main() method. // SuperMarket.java - This program creates a report that lists weekly hours worked // by employees of...

  • week_days<- c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") How do i write a line of code...

    week_days<- c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday") How do i write a line of code that will select the days Wednesday, Saturday, and Sunday in Rstudio?

  • Using the function you wrote in part 3a (refer to the bottom), write another function that, given the number of days in the month, and the day that the month starts on, the number of days that Inky Bl...

    Using the function you wrote in part 3a (refer to the bottom), write another function that, given the number of days in the month, and the day that the month starts on, the number of days that Inky Blinky Pinky and Clyde will get to play pinball in that month. The function provided will increment the day of the week to the next correct day. Function written in 3a): def pinball(dayOfWeek, dayOfMonth) : if dayOfMonth % 4 ==0: return "Pinky"...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT