I am Evrol Bell from Kingston Jamaica I have already found this site and the forums it offers very useful give thanks I just started learning C++ like a month ago this is the assignment I got from my facilitator she said it will be graded I wrote as much as I can but I know something is wrong so I need all the input I can get its outline below with the code I wrote at the end give thanksA program is required by a company to store employee’s number, TRN number pay rate and the number of hours worked in a week. The program is then to validate the pay rate and the hours worked fields and, if valid compute the employee’s weekly pay and print it along with the input data on to a payslip
Validation: According to the company’s rules, the maximum hours an employee can work per week is 40 hours, and the maximum hourly rate is $200.00 per hour. If the hours worked fields or the hourly rate is out of range, the input data and the appropriate message is to be printed and the employee’s weekly pay is not to be calculated
Weekly pay calculation: Weekly pay is calculated as hours worked times pay rate. If more than 30 hours are worked, payment for the overtime hours worked is calculated at time-and-a-half.
Most employees are paid according to these procedures, but two categories of workers are paid differently.
Programmers have an area of speciality and can be assigned to only one project. They do not earn overtime, but they are entitled to a $5,000 bonus for each week their project is running ahead of schedule.
Sales representatives earn a commission of $2000 if their weekly sales exceed $20,000 and $1000 if their sales are in the range $10,000 to $20,000.
As the payroll is processed, the weekly pay for each employee should be added to the wages total for that week and printed after the last employee has been processed. All the data that has been printed on the payslips should be written to file.
This implementation must be done using C++ (Bloodshed C++) CODE
#include <iostream> // for keyboard/screen I/O
#include <fstream> // for file I/O
using namespace std;
void CalcPay ( float, float, float& );
const float MAX_HOURS = 40.0; // Maximum normal hours
const float OVERTIME = 1.5; // Overtime pay factor
int main( )
{
float payRate; // Employee’s pay rate
float hourswork; // Hours worked
float wages; // Wages earned
float total; // Total company payroll
int empNum; // Employee ID number
int trnnum; // Employee TRN number
int category;
ofstream payFile; // Company payroll file
payFile.open( “payfile.dat” ); // Open file
total = 0.0; // Initialize total
cout << “Enter employee number: “; // Prompt
cin >> empNum; // Read ID number
while ( empNum != 0 ) // While not done
{
cout << “Enter pay rate: “;
cin >> payRate; // Read pay rate
cout << “Enter hours worked: “;
cin >> hourswork; // and hours worked
cout << "enter employee trn number";
cin >> "trnnumber";
cout << "enter category of employee";
cin >> "category";
If (hoursworked > 40) && (pay rate > 200) then
Print input data
Print appropriate message
Salary not calculated
Else
If( category = = “programmer”)
“Prompt user for schedule time”
If schedule time = = yes
Bonus = 5000
Weeklypay = bonus + (hoursworked * hourlyrate)
Else
Weeklypay = hoursworked *hourlyrate
print (payslip) weeklypay , input data
ElseIf (category = =”sales rep”)
Prompt user to enter weekly sales
If (weeklysales > 20000)
Commission = 2000
Weeklypay = commission + (hourlyrate * hoursworked)
print (payslip) weeklypay , input data
Else
If (weeklysales > = 10000) && (weekly sales < = 20000)
Commission = 1000
Weeklypay = commission + (hoursworked + hourlyrate)
print (payslip) weeklypay , input data
Endif
Else
If (hours worked > 30) then
Overtime = 40 – hoursworked
Overtimepay = 40- hoursworked
Weeklypay = (30* hourlyrate)+ overtimepay
Else
weeklypay = hoursworked * hourlyrate
print (payslip) weeklypay , input data
Endif
Endif
Totalwages = totalwages + weeklypay
Print totalwages
Write File with EmpNumber,TrnNumber,HoursWorked,PayRate,Totalsalary
Endif code here
This post has been edited by adisajaja: 15 Apr, 2007 - 07:23 PM