Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

1

CS 416 – C# Programming
Laboratory Exercise 1 – Basic Arithmetic Operation in C#

Objective: To create a program that demonstrates the function of Visual C# objects and
Mathematical operators.

Instruction:
1. Start a new Visual C# Windows Application project.
2. Name your project as prjLabExer1.
3. Change the name of your form (Form1.cs) to frmLabExer1.vb.
4. Change the Name Property of your form to frmLabExer1.
5. Change the Text Property of your form (Form1) to “General Average Calculator”. See the
following figure for example:

6. Add five Text Box controls in your form with associated labels, the “First Grading”,
“Second Grading”, “Third Grading”, “Fourth Grading”, and “General Average”, and
arrange your objects in your desired location. See the following figure for example:
2

7. Change the Name Property of your Text Box controls to base on its purpose. (E.g.:
txtFirstGrading, txtSecondGrading, and etc.)
8. Add two Button controls in your form and change the Text Properties to “Compute” and
“Exit”. See the following figure for example:

9. Change the Name Properties of your Button controls to “cmdCompute” and “cmdExit”.
3

10. Transfer General Average text field and its associated label below of Compute and Exit
buttons.
11. Arrange your object to your desired position. See the following figure for example:

12. In your Compute button, make a code that will compute the General Average of First,
Second, Third, and Fourth Grading Grades from each corresponding text field and return
its value in General Average field. See the following formula for the computation of
General Average:

General Average = (First Grading Grade + Second Grading Grade + Third Grading
Grade + Fourth Grading Grade) / 4

13. In Exit button, make a code that will close your entire form.
14. Run and test your program.
15. Use the example values shown in the following figure to check the result of your
computation:
4

16. Save your project in your working folder.

Note: You can also save your file (the entire project) as you start building your
Graphical User Interface (GUI) but don’t forget to change the Project Name base on the
given instruction (e.g. prjLabExer1).

Prepared by: Mr. Joseph S. Joaquin


Instructor, CS 416 – C# Programming

You might also like