Professional Documents
Culture Documents
CMPE 30032 Practice Laboratory Exercise 2
CMPE 30032 Practice Laboratory Exercise 2
CS 416 – C# Programming
Objective: To create a program that demonstrates the function of MS Visual Studio objects and
Mathematical operations.
Instruction:
1. Start a new Visual C# 2010 Windows Application project.
2. Name your project as prjPracLabExer2. Save your file in your working folder. See
the following figure for example:
3. Change the Text Property of your form (Form1) to “Gross and Net Pay Calculator.” The
following steps demonstrate:
Note: Do not remove the “.cs” extension to your form to let your Visual C#
project recognize your file.
3
5. Add three Group Box controls in your form. From the Toolbox Window, select
GroupBox from Containers group of items. See the following figure for example and
the following steps demonstrate:
3. Move and resize the first Group Box control to your desired location. See
the following figure for example:
4
4. Change the Text Property of your Group Box control to “Gross Income”. See
the following figure for example:
5. Add two more Group Box control below of Gross Income and change the Text
Properties to “Deductions” and “Net Income”. Resize your form if necessary
for your group box controls. See the following figure for example:
5
6. Add a two Button controls in your form (below of Net Income group box control),
the Compute and Exit buttons. Change the Name property of Compute button to
“cmdCompute” and Exit to “cmdExit”. See the following figure for example:
6
7. Add a three Text Box controls in your Gross Income group box with an associated Label,
the “Hours Worked”, “Pay Rate”, and “Gross Income”. See the following figure for
example:
10. Change the Name Property of your new Text Box controls in Deductions group box to
“txtSSS”, “txtPagIbig”, “txtPhilhealth”, “txtOthers”, and “txtTotalDeductions”. You can
refer to its associated labels for the possible names.
11. Add a Text Box control in your Net Income group box with associated label, the “Net
Income”. Resize your group box control if needed. See the following figure for
example:
12. Change the Name Property of your new Text Box control in Net Income group box to
“txtNetIncome.”
13. Double-click your Compute button and type the following codes between the private
And }.
txtGrossIncome.Text = GrossIncome.ToString();
See the following figure below for your example code listed in Visual C# code editor.
14. Type Close() in your cmdExit button control procedure. See the following code
listing below for example:
10
15. Run and test your program (the Gross and Net Pay Calculator). Enter the
following values from the given interface below:
Note: Gross Income, Total Deductions, and Net Income should be blank for there is
already an associated code to assign its value as you click the Compute button.
Please study and understand the given codes in your Compute button.
11
16. Click the Compute button to let your program compute for the “Gross Income,” “Total
Deductions,” and the “Net Income.” See the following figure for example:
17. Click the Exit button to close your form (running program).
18. Save your project in your working folder.
Note: Prepare for your Laboratory Exercise 1. Please always read and understand the given
instructions. Read and learn from error messages as you move to the next level of Visual C#
programming.