Files and Input #include #include #include #include using namespace std; int main() {     //Declare variables     string employee;     double RateOfPay, salary;     int hours;

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Files and Input

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;

int main() {

    //Declare variables
    string employee;
    double RateOfPay, salary;
    int hours;
    cout << fixed << setprecision(2);

    ifstream in("WorkLoad.txt");
    getline(in, employee);
   
    in >> RateOfPay >> hours;
    

    in.close();

    salary = hours * RateOfPay;
    if (hours > 38)
        salary = (38 * RateOfPay) + ((hours - 38) * RateOfPay * 1.5); 
    else
        salary = hours * RateOfPay;

    cout << employee << " worked " << hours << " hours at a rate of pay of " << RateOfPay << ". Due to the number of hours worked the employee did ";
   
    (hours > 38) ? cout << "" : cout << "not ";
    cout << "qualify for time and a half pay. The weekly salary for this employee is " << salary << endl;
  
    // open output file Salary.txt for writing
    ofstream out("Salary.txt");
    out << fixed << setprecision(2);

    // write output to the output file
    out << employee << " worked " << hours << " hours at a rate of pay of " << RateOfPay << ". Due to the number of hours worked the employee did ";
   
    (hours > 38) ? out << "" : out << "not ";
    out << "qualify for time and a half pay. The weekly salary for this employee is " << salary << endl;
   
    out.close();

    return 0;
}

 

Add to the input file WorkLoad.txt of assignment above so that it contains at least 10 employees, in the following format:
First name Last name  (2 words)
RateofPay hourWorked (2 numbers)
__________________________________
Line One is the employee’s name, first and last
Line Two is the Rate of Pay followed by the number of hours worked 
Your data should contain at least one employees from each category (worked  overtime, exactly 38 hours, and less than 38 hours).
Your program is to read in the data contained in the file until end of file is reached.  You do not know in advance how many records are in the file
1. If the employee worked more than 38 hours they are to receive time and a half for all the hours worked over 38
2. If the employee worked 38 or fewer hours their salary is hours worked times rate of pay
3. Calculate the weekly take home pay of that employee
4. Print your results on the screen in the following format:
[Employee]  worked  [hours] at a rate of pay of [Rate of Pay].  Due to the number of hours worked the employee [did/did not] qualify for time and a half pay.  The weekly salary for this employee is [salary].
5. What is the average salary of all your employees?

This output is also to be written to an output file Salary.txt
Note:
 Employee, hours worked, and Rate of Pay are read in from the input file.  
Whether or not the employee qualified for time and a half and the computed salary are based upon the results of an if statement.
Submit the following files:
Copy of input file
Your program with the screen output attached
Copy of the output file

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY