473,786 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::setprecisi on;

//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 5379
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
2454
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 this formula but it is probably way off trak , for it is giving me an error stating that it will match to many records. ANYONE PLEASE HELP..... Total Time in Minutes: DateDiff("n",,)/60 -- Message posted via http://www.accessmonster.com
3
2091
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? SELECT ., .Date, ., IIf(<=8,,8) AS , Sum((-)) AS Ot FROM GROUP BY ., .Date, ., IIf(<=8,,8); -- Message posted via http://www.accessmonster.com
5
12993
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 works with overtime but has the same feilds within the table. I want to be able to run a report that combines the regular time and overtime for the warehouse and seperated by each customer. I have tried join tables but I keep ending with, (if it...
3
2268
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 the payroll. I have employee normal, time/half and double time rates in $value in one table, then in another I have log in and out times; then another job start and stop time. I realize the code is probably logical-but I am not brilliant with
3
1679
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 difficult to get that rate? In other words, does management hangle and bicker with you and in the end make you end up working for the $50 rate? How practical is it for a skilled C# developer to work from contract to contract? Short term: 3 - 9...
0
1684
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: ----------------------------------------------------------- SELECT DateFilter.Employee, DateFilter.TimeTypeIn, Sum(DateDiff("s",,))\3600 &
1
2413
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 on the salary details (Basic, Allowances etc) and the attendance (days worked and overtime hours). Overtime pay should be based on the basic only. Maybe the following codes/syntax (from microsoft) will help. To refer to a control on a subform,...
3
2902
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 = Like "Saturday Rota" Or Like "Sat Rota" Or Like "Rota"
1
2477
cori25
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 come to the point where I am pulling out the duplicate date's in a query. Name Date Shift Reliability Buck, Jack 1/2/2008 4:00 PM-12:30 AM 0.16254 smith, frank 1/2/2008 4:00 PM-12:30 AM 0 Jones,...
0
9492
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10360
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9960
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.