


Thread Tools  Display Modes 
Mar 27th, 2009, 10:37 AM  #1 
Newbie
Join Date: Mar 2009
Posts: 3
Rep Power: 0

Please help me. weekly pay calculator
Please help me someone!!
I have this homework assignment where we have to create a pay calculator where you would enter the total minutes worked and the hourly pay rate. and then i have to create the code to show what the total weekly pay would be. I have to display the Hours Worked: and the Leftover minutes: I also know that the formula to calculate the weekly pay is totalMinutesWorked / 60 = hoursWorked and i have to use the Mod operator, but I cant figure out what I am doing wrong. If anyone can look at my code below and help me out I would really appreciate it. Private Sub btnWeeklyPay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWeeklyPay.Click Dim strNumberOfMinutes As String Dim intNumberOfMinutes As Integer Dim strPayRate As String Dim decPayRate As Decimal Dim decTotalWeeklyPay As Decimal Dim intHoursWorked As Integer Dim intLeftoverMinutes As Integer Dim decLeftoverMinutes As Decimal Dim intTotalMinutesWorked As Integer strNumberOfMinutes = Me.txtTotalMinutesWorked.Text intNumberOfMinutes = Convert.ToInt32(strNumberOfMinutes) strPayRate = Me.txtHourlyPayRate.Text decPayRate = Convert.ToDecimal(strPayRate) intHoursWorked = intNumberOfMinutes \ 60 intTotalMinutesWorked = Convert.ToInt32(txtTotalMinutesWorked) txtTotalMinutesWorked Mod 60 = intHoursWorked decTotalWeeklyPay = decLeftoverMinutes + intHoursWorked * decPayRate Me.lblTotalWeeklyPay.Text = decTotalWeeklyPay.ToString("C") Me.lblHeadingHoursWorked.Visible = True Me.lblHeadingLeftoverMinutes.Visible = True Me.lblWeeklyPay.Visible = True Me.lblTotalWeeklyPay.Visible = True Me.lblHoursWorked.Visible = True Me.lblLeftoverMinutes.Visible = True 
Mar 27th, 2009, 12:57 PM  #2 
Expert Programmer
Join Date: Mar 2005
Posts: 777
Rep Power: 11

Re: Please help me. weekly pay calculator
It looks like you have the mod operator on the wrong side of an equals... I'd expect something like
intLeftOverMinutes = intTotalMinutesWorked mod 60
__________________
I can remember, back in '22 They changed the law  came knocking on the door In that same moment, the broadband seemed to go.. Phones all dead. Gone dizzy in the head.. 
Mar 27th, 2009, 5:06 PM  #3 
Expert Programmer
Join Date: Feb 2009
Posts: 639
Rep Power: 7

Re: Please help me. weekly pay calculator
dont for get to take out taxes acccording to the pub15

Mar 28th, 2009, 12:59 AM  #4 
Hobbyist Programmer
Join Date: Mar 2009
Posts: 117
Rep Power: 7

Re: Please help me. weekly pay calculator
Just another note... this is the vb classic version 6 forum. your post should have been in the .net forum.
With that said, your calculation (could be wrong) does not seem to (from what I read) return the correct amount, not only because of operator precedence but because of your formula. With operator precedence all multiplication and division is done prior to any addition or subtraction so your forumla... decTotalWeeklyPay = decLeftoverMinutes + intHoursWorked * decPayRate 5 hours worked times 10.00 dollars and hour equals 50.00 plus 27 minutes equals 77.00 dollars. The easiest way I can think of to sort this out is to take rate of pay per hour divided by 60, times number of minutes worked... Weekly pay = (hourly rate \ 60 minutes in the hour) * number of minutes worked the above formula states via the parens "()" that we want this operation done first before we multiply that result by the number of minutes worked. Good Luck 
Mar 28th, 2009, 9:35 AM  #5  
Expert Programmer
Join Date: Mar 2005
Posts: 777
Rep Power: 11

Re: Please help me. weekly pay calculator
Quote:
Weekly Pay = hourly rate * hours worked. I don't think you get paid for the leftover minutes, but that's just a guess on my part, the OP doesn't seem to say.
__________________
I can remember, back in '22 They changed the law  came knocking on the door In that same moment, the broadband seemed to go.. Phones all dead. Gone dizzy in the head.. 

Mar 28th, 2009, 9:45 AM  #6 
Hobbyist Programmer
Join Date: Mar 2009
Posts: 117
Rep Power: 7

Re: Please help me. weekly pay calculator
Well in the united states that would be illegal. OP would have to check with local laws to see if it is okay for for businesses to rob their employees of earned wages if those earned wages do not fall on the hour, and then think about the person who worked X number of hours and 59 minutes!!!!

Mar 29th, 2009, 10:17 AM  #7 
Expert Programmer
Join Date: Feb 2009
Posts: 639
Rep Power: 7

Re: Please help me. weekly pay calculator
hours worked can be a decimal point. Most of the time no company will pay you by the min, usually 15mins, .25 .5 or .75. which hours * wage will work.
8.75 * 25 = total pay 
Mar 29th, 2009, 11:31 AM  #8 
Newbie
Join Date: Mar 2009
Posts: 3
Rep Power: 0

Re: Please help me. weekly pay calculator
Okay i changed some things around and now it comes up with the breakdown for the hours worked and the leftover minutes, but I am still not able to get it to calculate the total weekly pay. In the homework it does not say whether the minutes are to be paid in quarters or not, so I am assuming that I need to calculate for each minute and make the formula work according to that.
Dim intTotalNumberOfMinutes As Integer Dim strTotalNumberOfMinutes As String Dim intHourlyPayRate As Integer Dim strHoursWorked As String Dim intHoursWorked As Integer Dim strMinutesLeft As String Dim intMinutesLeft As Integer Dim decTotalWeeklyPay As Decimal strTotalNumberOfMinutes = Me.txtTotalNumberOfMinutes.Text intTotalNumberOfMinutes = Convert.ToInt32(strTotalNumberOfMinutes) strHoursWorked = Me.lblHoursWorked.Text intHoursWorked = Convert.ToInt32(strHoursWorked) strMinutesLeft = Me.lblMinutesLeft.Text intMinutesLeft = Convert.ToInt32(strMinutesLeft) decTotalWeeklyPay = (intHourlyPayRate \ 60) * intTotalNumberOfMinutes intHoursWorked = intTotalNumberOfMinutes \ 60 intMinutesLeft = intTotalNumberOfMinutes Mod 60 Me.lblHoursWorked.Text = intHoursWorked.ToString("G") Me.lblMinutesLeft.Text = intMinutesLeft.ToString("G") Me.lblTotalWeeklyPay.Text = decTotalWeeklyPay.ToString("C") this is only a simulation assignment and not actually meant to generate wages for a real company, so the legal issues dont really matter. 
Mar 29th, 2009, 2:03 PM  #9 
Expert Programmer
Join Date: Mar 2005
Posts: 777
Rep Power: 11

Re: Please help me. weekly pay calculator
Can you explain more of your problem, you say it "doesn't generate the weekly wage" why not? What does it do, what's the issue?
It's hard (especially for those not bothering to run your program) to figure out why it might not work without knowing what's going wrong.
__________________
I can remember, back in '22 They changed the law  came knocking on the door In that same moment, the broadband seemed to go.. Phones all dead. Gone dizzy in the head.. 
Mar 29th, 2009, 2:58 PM  #10 
Newbie
Join Date: Mar 2009
Posts: 3
Rep Power: 0

Re: Please help me. weekly pay calculator
Okay, i am new to Visual Basic but I will try to explain what is being asked. The program, when ran correctly will display a form that you enter the total minutes worked and the hourly pay rate. then when you click the submit button, it is supposed to come back with the total hours worked, the leftover minutes from the hours, and then display the total weekly pay based off of the minutes worked. The problem that i am having is that it is displaying $0.00 for the total weekly pay. Example: you input 1830 minutes and a pay rate of 19.75 an hour, it should return a result of Hours worked: 30 Leftover Minutes: 30 Weekly pay: $602.38. No matter what I try though, it is not displaying the weekly pay correctly. I hope this clarifies a little and thank you very much for the help. I did originally have the mod operator on the wrong side, so i fixed that and changed the formula like someone else posted but I am stuck on this and dont know what the heck the problem is.

Bookmarks 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)  
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Calculator Issues  charlie 22  C  2  Mar 25th, 2009 10:49 AM 
Another gross/net pay program  Booost  Java  3  Feb 11th, 2009 8:47 PM 
JAVA.. I can't display the right GROSS PAY and NET PAY solution.?  antitru5t  Java  2  Feb 9th, 2009 7:13 PM 
A Payroll Calculator  tjohnny76  Visual Basic .NET  3  Dec 4th, 2008 11:23 AM 
Javascript calculator  narroweyes  JavaScript and ClientSide Browser Scripting  7  Jul 30th, 2005 12:46 PM 