472,993 Members | 2,191 Online

# Calculating overtime

here's my dilemma, on the program below, i am trying to calculate overtime
pay at time and a half, but instead of only counting the hours after 40, it
counts all hrs at that rate, how can i avoid this? thanks.

// figures hourly wages for employees

#include <iostream>
#include <conio.h>

using std::cout;
using std::cin;
using std::fixed;

#include <iomanip>

using std::setprecision;

//function main begins program execution
int main()
{
int total; // represents salary
int hrs; // represents hours worked
int rte; // represents rate paid
int ovr; // represents overtime pay

total = 0;
ovr = 0;

cout << "Enter hours worked (-1 to end):";
cin >> hrs;

while ( hrs != -1 ) {
cout << "\nEnter hourly rate of the worker:";
cin >> rte;
if ( hrs > 40 );
ovr = ( rte * .5 * hrs );
total = ( hrs * rte + ovr );
cout << "\nSalary is \$" << setprecision ( 2 ) << fixed << total;

cout << "\nEnter hours worked (-1 to end:";
cin >> hrs;

if ( hrs < 0 );
break;
}

return 0;

}
Jul 23 '05 #1
2 5292
Eric Whittaker wrote:
here's my dilemma, on the program below, i am trying to calculate overtime
pay at time and a half, but instead of only counting the hours after 40, it
counts all hrs at that rate, how can i avoid this? thanks.

int base_hours = hrs;
int overtime_hours = 0;
if(hrs > 40) {
base_rate = 40;
overtime_hours = hours-40;
}
Jul 23 '05 #2
Eric Whittaker wrote:
here's my dilemma, on the program below, i am trying to calculate overtime
pay at time and a half, but instead of only counting the hours after 40, it
counts all hrs at that rate, how can i avoid this? thanks.
[...]

Forget the code for a minute. Let's just do it on a piece of paper...

If I worked 60 hours, my rate of pay is 25 bookers/hr, how much should I
be paid total? If you figured that I should be paid 1750 bookers, you
are correct. Now, how did you arrive to that number? Now, fix the 'ovr'
and 'total' calculation in your code.

V
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

### Similar topics

 3 by: Jamie Pittman via AccessMonster.com | last post by: I am currently working on a project to take an employees time for a day and and if over 8 hours it would move those extra hours to overtime row amd not caculate into regular time. I started to use... 3 by: Jamie Pittman via AccessMonster.com | last post by: I am having trouble bellow wit this query. I have the total regular hours and the overtime. The problem is that if it is 8 hours and under, I need it to show as regular hours. Any thoughts? ... 5 by: Jamie Pittman via AccessMonster.com | last post by: I have two tables with 5000 entries on them. One is based for regular time with several variables example (employee name, date,time in and out, code, customer, building) I have another table that... 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... 3 by: Brett | last post by: For those of you working hourly, are you paid time and a half for anything over 40 hours? Say you are making \$50/hour. Once you go over 40, your rate goes up to \$75. If so, do you find it... 0 by: Drum2001 | last post by: I have designed a "Time Tracker Database"... Basically a Time Clock. I have report that calculates the number of regular hours worked per week. Currently I am running the following query:... 1 by: hakunamatata5254 | last post by: Hi all, In my project of multiple forms (main form, subform1, 2 , 3 etc) (Main form is Employees, Subforms are Attendance, salary details, payment) Now i want to calculate the payment based... 3 by: foxykitty | last post by: Hi, How can I group in my qryMonthlyHours in SQL view by , and then sum done in that month? I have another query - qrySaturdayRota ,,,,, ALL THIS IS GROUPED EXCEPT FOR has a criteria... 1 by: cori25 | last post by: Employee's input the shifts they want, once I have all this data I need to determine who will get what shifts depending on a reliability %, if thats the same then I look at the time stamp. I have... 0 by: Aliciasmith | last post by: In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app... 0 by: tracyyun | last post by: Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to... 4 by: NeoPa | last post by: Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :... 3 by: NeoPa | last post by: Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all... 1 by: Teri B | last post by: Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and... 0 by: isladogs | last post by: The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on... 0 by: isladogs | last post by: The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike... 4 by: GKJR | last post by: Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other... 3 by: SueHopson | last post by: Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...