473,378 Members | 1,500 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.

C++ Overtime and Payroll Calculations

2
Hello all, when you execute my code you'll notice the regular pay for the first example will calculate to $500 when it is only supposed to calculate to $400. I'm also having a problem adding up the totals of the regular pay and overtime pay to get a total payroll which is displayed in one cout statement. 95% of my code is correct, I'm just having these two issues, any help is appreciated. To make it more clear hear is my assignment:

The regular working hour for an employee is 40 hours a week. Sometimes employees work over time. When the employee works 40 or less hours, the regular pay is calculated as number of hours worked times the hourly rate. When the employee works over time i.e. beyond 40 hours then the employee’s pay has two components a) regular pay (40 hours X hourly rate), and 2) overtime pay (the overtime hours beyond 40 X time and half of the hourly rate).

Expand|Select|Wrap|Line Numbers
  1. void compute(incomeInfo *ptrI, int count)    
  2. {                                                
  3.     for (int i = 0; i<count; i++)
  4.  
  5.     if (ptrI->hours <= 40)
  6.     {
  7.         ptrI->regPay = ptrI->hours * ptrI->hRate;
  8.         ptrI++;
  9.     }
  10.  
  11.     else if (ptrI->hours > 40)
  12.     {
  13.         ptrI->regPay = ptrI->hours * ptrI->hRate;
  14.         ptrI->otPay = (ptrI->hours - 40) * (ptrI->hRate + (ptrI->hRate* .5));
  15.         ptrI++;
  16.     }
  17.         return;
  18. }
  19.  
  20.  
  21. void summary(incomeInfo income[], int count)
  22. {
  23.  
  24.     for (int i = 0; i < count; i++)
  25.         cout << endl << endl << "Total payroll amount for the company = " << income[i].regPay + income[i].otPay <<endl;
  26.  
  27.     system("PAUSE");
Apr 11 '14 #1
1 2016
weaknessforcats
9,208 Expert Mod 8TB
You didn't post the type of your variables.

I am assuming you are not using floating point. If you are, then remove it and replace with integers. Floating point is for scientific use where accuracy is not required.

If an int contains the amount in pennies, you add the decimal point and the $ at time of display. So if you are in pennies and the value is 12345, you display $123.45 by:

Expand|Select|Wrap|Line Numbers
  1. cout << "$" << value/100 << "." << value %100 << endl;
  2.  
  3.  
value/100 is the dollars and value % 100 is the remainder after dividing value by 100, that is, the pennies.
Apr 11 '14 #2

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

Similar topics

1
by: Randi | last post by:
Hi, Looking for some help with this payrool project I have for class. This is what the instructor asks for so far. I have it working without errors but am getting some funky numbers. I am not...
0
by: zexx | last post by:
Need some advise.... Payroll program Access97. Payroll is printed then posted to a hx table thro' a query with the payroll calculations that freeze that payroll's numbers for that period. The...
3
by: michb | last post by:
I need to be able to calculate on a daily basis, both normal and overtime hours for both payroll and job costing. I also then need to calculate the above on a weekly basis, in order to complete...
4
by: Mark T. | last post by:
Hi all, New to Access...... Trying to create a payroll database for employees who are paid on the 1st and the 15th of the month. This is quite different than every 2 week pay periods. ...
8
by: John Sitka | last post by:
Hi, There are four pay types standard shiftpremium doubletime doubletimepremium each hour a person books can be one of these types
2
by: isoquin | last post by:
I have frmMain that takes in data about a particular event. Payroll information needs to be automatically calculated from this, but is stored in a different table. So, I included a subform frmPay,...
16
by: shreyansghia | last post by:
Hello, I am a new member and am glad to a part of this forum. I am facing a slight problem while doing time calculations in MS access. I ve prepared a time sheet for my workers. Their regular...
1
by: jjchatting54 | last post by:
I need help getting output from my code when I compile, the codeblocks ide doesnt show any errors it just doesn't give me any out put when I compile? can you help me? Here is my code: #include...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.