1 assignment objectives learn to use: 1. textboxes, labels, butttons, picture boxes, properties,...
TRANSCRIPT
1
ASSIGNMENT OBJECTIVES
LEARN TO USE:
1. Textboxes, labels, butttons, picture boxes, properties, radio buttons, checkbox, and methods, group boxes
2. Arithmetic computations
3. Variables and constants
4. IF THEN ELSE statements and CASE logic
5. Me.Close()
6. txtTextBox.Clear() and lblLabel.Text = “”
7. Procedures, Arguments and Parameters, ByVal and ByRef
8. FormatCurrency() and FormatNumber() functions
9. Use Google for help on FormatCurrency and FormatNumber.
DIFFICULTY LEVEL: DIFFICULT
TUTORING CENTER IS NOW OPEN
START ON THE PROGRAM NOW.
Know Chapters 1, 2, 3, 4 and 6 for this program.
Spring 2015
2
GETTING HELP:You may ask another student for help, but you must not copy their code. Failure of the course will result for the person giving the code and the person receiving the code.
REMEMBER: THE GRADES IN THIS COURSE ARE CURVED.
I can get limited help from other students. For additional help, I need to see Dr. Scanlan, or the tutoring center.
3
1. The GUI MUST look almost exactly like the one displayed below.
2. Use FormatCurrency() and FormatNumber() functions to display the amounts. Use dollar signs for Gross andNet pay and Totals only.
3. Use Me.Close to close the program
5. Use any picture of a coffee shop you can find bysearching Google Images.
6. If Hours worked are over 40 then the employee receivestime and one-half for the hours over 40.
7. Note: There are changes on the form from Program #2.
8. The Clear Button clears all amounts, Radio Buttons, and CheckBoxes.
9. Be sure to use dollar signs for Totals, Gross Pay andNet Pay.
Due Date: April 16, 2015Points: 60Late penalty: 50% per class dayPrograms are ONLY accepted at the START of the class period on the date due.General Requirement: Create a payroll calculator for a Coffee ShopSpecific Requirements: Modularize Program
4
10. You are to modularize the program according to the hierarchy chart below. The code for the Main Module and the Validate Data modules are given on the following slides.
11. Use lblLabel.Text = “” and txtTextBox.Clear() to clear labels and textboxes.
12. You may NOT use module-level variables. You must communicate between modules using arguments and parameters.
13. Use ByRef only when you are passing a value back to the calling module.
14. You must add a range test to the Validate Data module: Range: Hours Worked: 1 through 60 Range: Pay Rate: 10 through 15
15. You must use the code supplied on the next slides.
Main Module
Validate DataCalculate Gross Pay
Calculate Taxes
CalculateHealth Insurance
CalculateNet Pay
Display Deductions
Display Gross Pay &
Net Pay
Clear Close
Boss Module
5
Option Strict On 'You must use Option Strict On
Public Class CalculateForm
Inherits System.Windows.Forms.Form
'CONSTANT DECLARATIONS
Const decFEDERAL_TAX_RATE As Decimal = 0.2D
Const decSTATE_TAX_RATE As Decimal = 0.1D
Const decCARBON_TAX_RATE As Decimal = 0.1D
Const decMEDICAL_INSURANCE_RATE_PLAN_A As Decimal = 0.05D
Const decMEDICAL_INSURANCE_RATE_PLAN_B As Decimal = 0.02D
Const decMEDICAL_INSURANCE_RATE_PLAN_C As Decimal = 0.01D
Const decDENTAL_INSURANCE_RATE_PLAN_A As Decimal = 0.05D
Const decDENTAL_INSURANCE_RATE_PLAN_B As Decimal = 0.02D
Const decDENTAL_INSURANCE_RATE_PLAN_C As Decimal = 0.01D
Const decEYE_GLASSES As Decimal = 10D
Const decEYE_EXAM As Decimal = 5D
6
'MAIN MODULE
Private Sub btnCalcGrossPay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalcGrossPay.Click
'VARIABLE DECLARATIONS
Dim decHoursWorked As Decimal
Dim decPayRate As Decimal
Dim decGrossPay As Decimal
Dim decFederalTax As Decimal
Dim decStateTax As Decimal
Dim decCarbonTax As Decimal
Dim decMedicalInsurance As Decimal
Dim decDentalInsurance As Decimal
Dim decVisionInsurance As Decimal
Dim decNetPay As Decimal
Dim decTotalTaxes As Decimal
Dim decTotalHealthDeductions As Decimal
Dim blnErrorFlag As Boolean = False
Call ValidateData(blnErrorFlag, decHoursWorked, decPayRate)
If blnErrorFlag = True Then
Exit Sub
End If
Call CalculateGrossPay(decHoursWorked, decPayRate, decGrossPay)
Call CalculateTaxes(decGrossPay, decFederalTax, decStateTax, decCarbonTax, decTotalTaxes)
Call CalculateHealthInsurance(decGrossPay, decMedicalInsurance, decDentalInsurance, _
decVisionInsurance, decTotalHealthDeductions)
Call CalculateNetPay(decGrossPay, decTotalTaxes, _
decTotalHealthDeductions, decNetPay)
Call DisplayDeductions(decFederalTax, decStateTax, decCarbonTax, decTotalTaxes, _
decMedicalInsurance, decDentalInsurance, decVisionInsurance, _
decTotalHealthDeductions)
Call DisplayGrossPayAndNetPay(decGrossPay, decNetPay)
End Sub
7
'VALIDATE DATA
Private Sub ValidateData(ByRef blnErrorFlag As Boolean, _
ByRef decHoursWorked As Decimal, _
ByRef decPayRate As Decimal)
Try
decHoursWorked = CDec(txtHoursWorked.Text)
Catch ex As InvalidCastException
MsgBox("Hours worked must be numeric.", MsgBoxStyle.Information, "Input Error")
txtHoursWorked.BackColor = Color.Yellow
txtHoursWorked.Focus()
blnErrorFlag = True
Exit Sub
End Try
Try
decPayRate = CDec(txtPayRate.Text)
Catch ex As Exception
MsgBox("Pay rate must be numeric.", MsgBoxStyle.Information, "Input Error")
txtPayRate.BackColor = Color.Yellow
txtPayRate.Focus()
blnErrorFlag = True
Exit Sub
End Try
End Sub
Don’t forget to add the range tests for Hours Worked and Pay Rate.
8
Warning: Attend to these grading criteria.
Failure to organized program according to Hierarchy chart - 60_____________
Failure to use ByVal and ByRef appropriately - 40_____________
Inputted Pay Rate or Hourly Rate values outside of Validate Data module - 60_____________
Failure to use Option Strict On- 40 _____________
9
Form-A
GRADER FILLS IN THIS PAGE:
PRINT LAST NAME:_______________________________
PRINT FIRST NAME:________________________
PROGRAM (Circle) 1 2 3 4 5 6 7 8 9
DATE DUE:_____________________
DATE SUBMITTED:___________________
GRADER FILLS IN THESE BLANKDESCRIPTION POINTS POINTS EARNEDAppropriate GUI: 0 OR 5 _____________Used Variable names and constants correctly 0 OR 5 _____________Failure to organized program according to Hierarchy chart - 20 _____________Failure to use ByVal and ByRef appropriately (-20 for each failure -20 to -60 _____________Inputted Pay Rate or Hourly Rate values outside of Validate Data module - 30 to -60 _____________Failure to use Option Strict On - 40 _____________Program runs correctly: -20 to -60 _____________Late penalty: -30 pts/class day _____________Zero points if the program fails to compile _____________.TOTAL POINTS OUT OF A POSSIBLE 60: _____________
FAILURE TO HAND IN THE PROGRAM ACCORDING TO THE REQUIRED PROCEDURE: see next slide: -5 points
Additional comments below:
ATTENTION
SPRING 2015
10
Form-B
STUDENT FILLS IN THESE BLANKS:
LAST NAME:_______________________________
FIRST NAME:_______________________________
PROGRAM (Circle) 1 2 3 4 5 6 7 8
DATE DUE:_________________
DATE SUBMITTED:__________________
PLACE A CHECK NEXT TO THE FOLLOWING:1. ____ Saved the Program on a CD-R or DVD-R using the following directory and
sub-directory: Drive Letter:\Your Name\Program22. ____ Printed your full name and program number on the CD or DVD-R using a
permanent black marker.3. ____ Submitted the CD or DVD-R in an envelope not to much larger than the CD.4. ____ Placed the CD or DVD-R in the envelope..
5. ____ Cut out this form along dotted edges and securely tape it to the envelope.
CUT OUT THIS FORM ALONG THE DOTTED EDGES AND TAPE IT TO AN ENVELOPE ABOUT THE SIZE OF A CD or DVD-R .
Be careful: Do notsave your programon your DVD-R or CDusing the USB format..
YOU MUST USE THIS STYLE THAT IS ABOUTTHE SIZE OF YOUR CD.Do not lick to seal. Usemetal clip.