473,378 Members | 1,449 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Adding to Code

Howdy...anyone able to assist me in adding the function to calculate the gross pay, and also the calculation and printing of the totals of hours and gross pay....thoughts?

/* Purpose: This program calculates the gross pay for employees.
* It allows the user to enter employee numbers, hours worked,
* and rates of pay, and calculates the gross pay.
* User input terminates when employee number is 0.
* The program also displays the totals of the hours
* and gross pays for all employees.
*/

#include <iostream>
#include <iomanip>

/* Function Prototype */

/* Main Program */

int main(void)
{
int empNum;
double hours, rate, grosspay;

cout << setprecision(2) << setiosflags(ios::fixed);

cout << "Please enter the employee number (0 to stop): ";
cin >> empNum;

while (empNum != 0)
{
cout << "Hours: ";
cin >> hours;
cout << "Rate: ";
cin >> rate;

grosspay = GrossPay(hours, rate);

cout << "\nGross Pay is " << grosspay;

cout << "\n\nPlease enter the employee number (0 to stop): ";
cin >> empNum;
}

cout << "\nThe total hours worked by all employees is " << endl;
cout << "\nThe total gross pay earned by employees is " << endl;

return (0);
}

/* Function: GrossPay
* Usage: grosspay = GrossPay(hours, rate);
* ----------------------------------------
* This function calculates the gross pay for an employee for the
* given number of hours worked (hours) and the rate of pay (rate).
* An employee is paid at the regular rate for the first 40 hours worked,
* at 1.5 times the rate for any hours over the first 40, and
* at 2 times the rate for any hours over the first 60.
*
* e.g. 62 hours at $10 per hour,
gives $400 for the first 40 hours,
* $300 for the next 20 hours, and
* $ 40 for the final 2 hours,
* ---- --
* thus $740 for the total 62 hours for a gross pay.
*/
Oct 30 '06 #1
0 1329

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: sp0 | last post by:
Is there a reason why to make mix numbers improper when adding? It seems when subtracting and adding, adding a subtracting the whole numbers and fraction parts should be sufficient? what'ch think
5
by: Tim | last post by:
I have block of code adding values to dropdown list under if (!Page.IsPostBack) { adding items } else { refreshing data }
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
5
by: Jeremy Ames | last post by:
I have run into a major road block with my page development projects. I am trying to add a literal control to my asp.net page and I got an error stating that the control could not be added because...
1
by: seanmayhew | last post by:
I have a form page that that while editing saves the data to an xml doc before submitting to db. On each page unload it saves the xmldoc as the user can add multiple items to the company like...
26
by: Simon Jefferies | last post by:
Hello, I am trying to add an item to a checked list box, like: clbList.Items.add("Hello",true) I get an error back: Run-time exception thrown: System.ArgumentOutOfRangeException -...
6
by: Rudy | last post by:
Hi all, I know this is easy, just can't seem to get it. I have a windows form, and a text box, with a value already in it. I need to add that value to a table. It's just one value, so the entire...
0
by: AndyL69 | last post by:
Hello I've got a very strange Problem. When im adding a new ACE entry to a UNC Direcotry the inherented ACL's will be lost. When I'm adding a new ACE to a directory / file in this UNC path the...
8
by: Jason | last post by:
Hello, I am trying to utilitze the AJAX Control toolkit in my asp.net project. I have added a reference to AjaxControlToolkit.dll, and in my page, added these lines of code: ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.