4 Replies - 815 Views - Last Post: 22 December 2011 - 08:30 AM Rate Topic: -----

#1 shardooni   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 28-October 11

How to write an application that evaluates weekly pay for an employee?

Posted 28 October 2011 - 07:13 PM

Okay so I need some help with my application. I am not sure if what I did here is correct. I needed to make an application that calculates weekly pay of employees at an hourly rate. The overtime schema is that:

- hours less than or equal to cutoff1 are paid regular rate
-hours over cutoff1 but not exceeding cutoff2 are paid 1.5 times regular rate
-hours over cutoff2 are paid double time or 2 times regular rate

Values of cutoff1 variables are:

30 for Category A
40 for Category B
50 for Category C

Values for cutoff2 variables are:

40 for Category A
60 for Category B
70 for Category C

The employee must choose Category A, B or C depending on the amount they have worked. I am completly new to visual basic, I am not sure how to continue with my if and then statements... I must also create the application with 3 radio buttons, where the user clicks either Category a b or c and then buttons which say calculate and clear. Some help please? My code is below.

Option Strict On


Public Class Form1

    Const cintNumberOfMinutesInHour As Integer = 60

    Private Sub btnweeklypay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWeeklyPay.Click

        ' This event handler is executed when the user clicks the

        ' Weekly Pay button. It calculates and displays the

        ' number of hours worked (total minutes worked divided by

        ' 60), the number of minutes worked (use mod operator to

        ' times hour remainder by 60), and the Total amount to

        ' be paid (hours worked times hourly pay rate).



        Dim strTotalMinutesWorked As String
        Dim intTotalMinutesWorked As Integer
        Dim strHourlyPayRate As String
        Dim decHourlyPayRate As Decimal
        Dim intTotalHoursWorked As Integer
        Dim intTotalLeftoverMinutes As Integer
        Dim decTotalWeeklyPay As Decimal

        strTotalMinutesWorked = Me.txtTotalMinutesWorked.Text
        intTotalMinutesWorked = Convert.ToInt32(strTotalMinutesWorked)
        strHourlyPayRate = Me.txtHourlyPayRate.Text
        decHourlyPayRate = Convert.ToDecimal(strHourlyPayRate)
        intTotalHoursWorked = intTotalMinutesWorked \ cintNumberOfMinutesInHour
        intTotalLeftoverMinutes = intTotalMinutesWorked Mod cintNumberOfMinutesInHour

        If cut1A <= 30 Then

            total = HRP * hours

        Else

            Total = HRP * 40

            hours = hours - 40

            Overtime = hours * HRP * 1.5

            Double time = 

            Total = total + overtime

        End If

        txttotal.text = total.tostring


        decTotalWeeklyPay = Convert.ToDecimal(intTotalMinutesWorked) / Convert.ToDecimal(cintNumberOfMinutesInHour) * decHourlyPayRate


        Me.lblTotalHoursWorked.Text = intTotalHoursWorked.ToString("")

        Me.lblTotalWeeklyPay.Text = decTotalWeeklyPay.ToString("C")

        Me.lblTotalLeftoverMinutes.Text = intTotalLeftoverMinutes.ToString("")



    End Sub



    Private Sub Btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click

        ' This Event Handler is executed when the user clicks the

        ' clear button. It clears the number of mintutes worked text box,

        ' the text property of minutes worked, the hourly rate text box,

        ' the textproperty of hours worked, and the text propoerty of

        ' weekly pay.



        Me.txtTotalMinutesWorked.Clear()

        Me.txtHourlyPayRate.Clear()

        Me.lblTotalHoursWorked.Text = ""

        Me.lblTotalWeeklyPay.Text = ""

        Me.lblTotalLeftoverMinutes.Text = ""

        Me.txtTotalMinutesWorked.Focus()



    End Sub



    Private Sub Btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

        ' This event handler is executed when the user clicks the

        ' Exit button. It closes the window and terminates the

        ' application.



        Me.Close()



    End Sub


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

This post has been edited by smohd: 28 October 2011 - 09:45 PM
Reason for edit:: Code tags added. Please use [code] tags when posting codes


Is This A Good Question/Topic? 0
  • +

Replies To: How to write an application that evaluates weekly pay for an employee?

#2 DimitriV   User is offline

  • vexing conundrum
  • member icon

Reputation: 587
  • View blog
  • Posts: 2,746
  • Joined: 24-July 11

Re: How to write an application that evaluates weekly pay for an employee?

Posted 28 October 2011 - 08:18 PM

Hey man - just a quick reminder. Please post between code tags
. It helps us read and distinguish the code from the question. Thanks for that.

Was This Post Helpful? 0
  • +
  • -

#3 DimitriV   User is offline

  • vexing conundrum
  • member icon

Reputation: 587
  • View blog
  • Posts: 2,746
  • Joined: 24-July 11

Re: How to write an application that evaluates weekly pay for an employee?

Posted 28 October 2011 - 08:27 PM

Also dont use spaces in variable names ((ie Double time) and don't just do this:
Double time = 

Do this:
doubleTime = Nothing

Its good, clean and simple programming practice.
J-Bo
Was This Post Helpful? 0
  • +
  • -

#4 shardooni   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 28-October 11

Re: How to write an application that evaluates weekly pay for an employee?

Posted 29 October 2011 - 04:44 AM

Alright thanks. You can't help me with my question?
Was This Post Helpful? 0
  • +
  • -

#5 BobRodes   User is offline

  • Lovable Curmudgeon
  • member icon

Reputation: 600
  • View blog
  • Posts: 3,071
  • Joined: 19-May 09

Re: How to write an application that evaluates weekly pay for an employee?

Posted 22 December 2011 - 08:30 AM

The only question I can see in your OP is "some help please?" and he gave you some help. If you want more specific help, then ask more specific questions.

This post has been edited by BobRodes: 22 December 2011 - 08:31 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1