Write a program that generates an Employee Payroll Report. The input for the program consists of a collection of data containing the last name, hourly pay rate, and the number of hours worked, for a set of employees. The output of the program is a report conforming to the sample layout found in DOC: Your program should perform the following tasks: Repeatedly prompt the user to determine whether or not there is data pertaining to an employee to be input. (Program should work for 0 or more employees.) If the user responds in the affirmative, the program prompts for each of the input data items for a single employee; the user responds in the negative when there is no more employee data to be processed. For each employee you are to compute the number of overtime hours worked by that employee, the salary, and the overtime pay. An employee earns straight time for the first forty hours of work, time-and-a-half for up to the first 10 hours in excess of 40 hours, and double-time for any additional hours. One report detail line should be generated for each employee. The report should include heading lines, column headings, and "footer" line as shown in the layout document. |
#include <iostream> #include <iomanip> #include <string> #include <windows.h> using namespace std; void input_employee (); void heading (); void gotoxy ( short x, short y ); char temp='N'; string name; int hour_rate, hours,over_hours; int main () { cout << "any workers ? Y/N: "; cin>> temp; heading(); while (temp=='Y' || temp=='y') { input_employee (); cout << "any workers ? Y/N: "; cin>> temp; } system("pause"); return 0; } void heading() { cout<< setw(50) << "EMPLOYEE PAYROLL REPORT - SPRING 2010" <<endl; for (int i=0; i<75;i++) cout << "-"; cout << endl; cout << " HOURLY OVERTIME OVERTIME TOTAL" << endl; cout << " NAME RATE HOURS HOURS SALARY SALARY" << endl; for (int i=0; i<75;i++) cout << "-"; cout << endl; } void input_employee() { cin>>name; gotoxy(9,7); cin>> hour_rate; } void gotoxy ( short x, short y ) { COORD coord = {x, y}; SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), coord ); } |