Write your question here.
Okay, so I've gotten what I think is a good start on this project, not sure though. I am confused on how to make my program be able to run for 0 to an infinite number of employees. I know its a loop but not sure how to prompt int main to run again after computing for an employee. I'm assuming I need a kill command of like "5" to stop the program. Also, I'm confused on how to get information from my main to get the program to go to the correct next function based on the employee type. I appreciate any advice and help you can give me:).
Here are the project directions.
Create a program that calculates and displays (to 2 places of decimal) the weekly gross pay of hourly employees and salaried employees.
The weekly gross pay of a salaried employee is calculated by dividing the employee’s annual salary by 52.
The weekly gross pay of an Hourly employee is calculated by multiplying the number of hours worked by the pay rate.
Create two separate functions (one each for the Hourly employees and the Salaried employees) as follows:
For the Hourly employee function, prompt for two values (hours worked and pay rate), and pass them to the function
For the Salaried employee function, prompt for one value (yearly salary), and pass it to the function.
Continue to request, calculate and display employee information until there is no more employee data to process. Your program must be able to process zero employees, to an infinite number of employees.
Demonstrate the use of the following in your solution:
Looping
Modularity (using functions)
Prompt for the type of employee to process, and invoke the Hourly Employee function or the Salaried employee function, depending on the type of employee pay the program’s user wants to process.
Except for the number of weeks in a year (52), there must be no hard-coded input in your program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#include "File.hpp"
#include <iostream>
using namespace std;
int Salaryemp(float yrsal);
int Hourlyemp(float hr, float wage);
float hr;
float wage;
float yrsal;
int emp;
int main()
{
cout << "enter employee type (1 for hourly and 0 for a salaried employee):";
cin >> emp;
if (emp == 1) // 1 = a hourly employee.
{
cout << "Enter hours worked this week:";
cin >> hr;
cout << "Enter horly pay:";
cin >> wage;
}
else (emp = 0); // 0 = a salaried employee.
{
cout << "Enter yearly salary:";
cin >> yrsal;
}
}
int Hourlyemp()
{
return 0;
}
int Salaryemp()
{
cout << yrsal / 52 << "is the weekly pay";
return 0;
}
|