MELJUN CORTES Technical faculty module part2 wsd
-
Upload
meljun-cortes -
Category
Technology
-
view
43 -
download
0
Transcript of MELJUN CORTES Technical faculty module part2 wsd
![Page 1: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/1.jpg)
Introduction to Computer Programming
MELJUN CORTESMELJUN CORTES
Visual Basic .Net Programming Using Visual Studio .Net
![Page 2: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/2.jpg)
Objectives
This module aims:• To introduce the software development process;• To know the different programming constructs of
Visual Basic .NET; and• To enhance the programming skills of the
participants.
![Page 3: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/3.jpg)
Topics
• The software development process
• Different Control Structures in programming
• Visual Basic .NET examples
• Lab Exercise
![Page 4: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/4.jpg)
The Software Development Process
1. Problem Analysis
2. Setting up an algorithm
3. Implementing your algorithm
4. Running, Testing, & Debugging
5. Documentation
![Page 5: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/5.jpg)
Problem!
Mr. De la Cruz needs a program to compute grades of 50 students. Grade computation is:
40% Average of 3 Exams
+ 40% Final Exam
20% Class participation
100%
Once grade of a student is computed the program also displays if student passed or failed. Passing grade is 70%.
![Page 6: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/6.jpg)
1. What are we asked to do?
Compute the final grade, and
determine if student is passing or not
1. Problem analysis
![Page 7: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/7.jpg)
2. What are the given data (inputs) and results that are to be produced (outputs)?
Input: Quiz No. 1 (Q1)
Quiz No. 2 (Q2) Quiz No. 3 (Q3) Final Exam (FE) Class Participation (CP)
Output: Final Grade (FG)
1. Problem analysis
![Page 8: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/8.jpg)
3. How do we accomplish our task?
FG = 40%
+ 30% (FE)
+ 15% (CP)
Q1 + Q2 + Q3
3
1. Problem analysis
![Page 9: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/9.jpg)
Algorithm a list or sequence of steps that solves the
given problemNote: The steps should be as detailed as
possible.
2. Set-up Algorithm
![Page 10: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/10.jpg)
Example:Step 1. Get Q1, Q2, and Q3 gradeStep 2. Get FE gradeStep 3. Get CP gradeStep 4. Calculate the FG using the formulaStep 5. Display the final grade FG
Step 6. Determine if student passed or failedStep 7. If students processed < 50,
go back to step 1 and process next student.
2. Set-up Algorithm
![Page 11: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/11.jpg)
Refining the algorithm
Step 6. Determine if student passed or failed
Step 6. Determine if student passed or failed
Step 6.1. If FG < 70%,
display student failed
otherwise,
display student passed
![Page 12: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/12.jpg)
3. Implementing the algorithm
Basic Questions:1. How do you get input and display output?2. How do you store information?3. How do you write formula?4. How do you make a program perform statements
depending on different situations?5. How do you make a program repeat parts of itself?
![Page 13: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/13.jpg)
Getting input and output
Using consoleImports System
Public Module Hello
Public Sub Main( )
Console.WriteLine("hello, world")
End Sub
End Module
![Page 14: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/14.jpg)
Screen output
![Page 15: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/15.jpg)
Getting input and output
Demo using GUI
![Page 16: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/16.jpg)
How do we store data?
Answer: Use variables
Declaring variables:
Dim variable As datatype
Rules:1. Must begin with a character or underscore2. Cannot have special characters3. Cannot be a reserved word
![Page 17: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/17.jpg)
Basic data types in VB .NET
Numerical:
Integer (whole numbers)
Float (floating point)
Non-numerical:
Boolean (true or false values)
Char (a single character)
String (many characters)
![Page 18: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/18.jpg)
Sample Declaration
Dim finalGrade As Float
Dim quiz1 As Integer
Dim name As String
Programming Tips…
1. Use descriptive variable names2. Don’t use names that differ by only one character
ex. Dim final As Float Dim finals As Float
3. Use names that are not too long and not too short
![Page 19: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/19.jpg)
Branching constructs
The If statement
Syntax 1: If expression Then
statements
End If
![Page 20: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/20.jpg)
Example
For the problem of Mr. dela Cruz, to determine if a student passed or failed, we use:
If finalGrade >= 70 Then
Console.WriteLine(“Passed”)
End If
If finalGrade < 70 Then
Console.WriteLine(“Failed”)
End If
![Page 21: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/21.jpg)
Branching constructs
The If statement
Syntax 2: If expression Then
statements
Else
statements
End If
![Page 22: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/22.jpg)
Example
For the problem of Mr. dela Cruz, to determine if a student passed or failed, we use:
If finalGrade >= 70 Then
Console.WriteLine(“Passed”)
Else
Console.WriteLine(“Failed”)
End If
![Page 23: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/23.jpg)
Branching constructs
The If statement
Syntax 3: If expression Thenstatements
ElseIf expression Thenstatements
ElseIf expression Thenstatements
Elsestatements
End If
![Page 24: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/24.jpg)
Example
If finalGrade >= 90 Then
Console.WriteLine(“Very Good”)
ElseIf finalGrade >= 80 Then
Console.WriteLine(“Good”)
ElseIf finalGrade >= 70 Then
Console.WriteLine(“Satisfactory”)
Else
Console.WriteLine(“Needs Improvement”)
End If
![Page 25: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/25.jpg)
Looping constructs
• Allow a group of statements to be executed more than once
• Looping statements in VB .NET:– Do– For– For Each
![Page 26: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/26.jpg)
Looping constructs
The Do statement
Body of the loop is executed either:
1. while a condition remains true; or
2. until the condition becomes true
![Page 27: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/27.jpg)
Looping constructs
The Do statement examples
Do While count < 50' statements
Loop
Do Until count > 50' statements
Loop
Do ' statementsLoop While count <= 50
Do ' statementsLoop Until count >= 50
Do ' statementsLoop
![Page 28: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/28.jpg)
Looping constructs
The For statement
• Body of the loop is executed a fixed number of times
• Looping is controlled by a loop control variable
![Page 29: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/29.jpg)
Looping constructs
Syntax of For statement:
For var = expr To expr [ Step expr ]
statements
Next [ variable_list ]
![Page 30: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/30.jpg)
Looping constructs
Example of For statement:
For i = 1 To 10
Next
For i = 1 To 10
For j = 1 To 10
Next i, j
For i = 1 To 10
For j = 1 To 10
Next
Next
![Page 31: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/31.jpg)
Different bugs or errors encountered:
• Syntactical errors are caused by deviating from grammatical rules of the language.
• Logical errors are caused due to faulty algorithm formulation
4. Run, Test, debug
![Page 32: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/32.jpg)
Reasons for doing documentation:1. Ease of understanding different parts of the
code.2. Reduces efforts during program maintenance
and problem reconstruction.
Internal Documentation in VB .NET:‘ This is a comment
5. Documentation
![Page 33: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/33.jpg)
.NET Hands On Exercises
![Page 34: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/34.jpg)
Exercises
• Lab1: Flash Cards
• Lab2: XChange
• Lab3: Student Picker
• Lab4: Mine Sweeper
![Page 35: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/35.jpg)
Flash Cards
• Objectives– Design a graphical user interface.– Modify the properties of the user controls.– Create and call functions.– Perform input and output operations.– Create and evaluate statements and
expressions.– Implement and analyze program branching.
![Page 36: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/36.jpg)
Flash Cards
• Features– Generates random
algebra problems.– Checks user input if
correct or incorrect.– Optional: scoring
– Optional: hints
![Page 37: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/37.jpg)
Flash Cards
• Creating the GUI– Drag and drop controls from the toolbox.– Use the properties window to modify the windows
controls.– Change the names of the controls.
![Page 38: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/38.jpg)
Flash Cards
• Declaring Variables
![Page 39: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/39.jpg)
Flash Cards
• Creating Functions
![Page 40: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/40.jpg)
Flash Cards
• Generating the problem
![Page 41: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/41.jpg)
Flash Cards
![Page 42: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/42.jpg)
Flash Cards
![Page 43: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/43.jpg)
Flash Cards
• Checking the answer
![Page 44: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/44.jpg)
Flash Cards
• Giving hints
![Page 45: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/45.jpg)
XChange
• Objectives– Modify the properties of the user controls.– Create and call functions.– Convert data types.– Create and evaluate statements and
expressions.– Handle Windows control events.
![Page 46: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/46.jpg)
XChange
• Features– Converts one value to
another based on a given formula.
– Customizable conversion functions.
![Page 47: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/47.jpg)
XChange
• Synchronize TrackBar and Label
![Page 48: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/48.jpg)
XChange
• Convertion Functions
![Page 49: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/49.jpg)
XChange
• Convert Left Value
![Page 50: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/50.jpg)
XChange
• Convert Right Value
![Page 51: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/51.jpg)
XChange
• Dollar to Peso Conversion
![Page 52: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/52.jpg)
XChange
• Grade Equivalent of 70 pt Exam
![Page 53: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/53.jpg)
XChange
• Other Applications– Celsius to Fahrenheit– Pounds to Kilos– Inches to Centimeters– Etc.
![Page 54: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/54.jpg)
Teaching Assistant
• Objectives– Call functions and pass parameters– Practice looping constructs and conditions– Work with list controls– Use the features of collections– Handle file input and output
![Page 55: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/55.jpg)
Teaching Assistant
• Features– Class attendance
checker– Random student
selection– Load/Save class lists
![Page 56: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/56.jpg)
Teaching Assistant
• Adding new students
![Page 57: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/57.jpg)
Teaching Assistant
• Deleting students
![Page 58: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/58.jpg)
Teaching Assistant
• Checking class attendance
![Page 59: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/59.jpg)
Teaching Assistant
• Checking class attendance
![Page 60: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/60.jpg)
Teaching Assistant
• Checking class attendance
![Page 61: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/61.jpg)
Teaching Assistant
• Create a random function
![Page 62: MELJUN CORTES Technical faculty module part2 wsd](https://reader034.fdocuments.in/reader034/viewer/2022042701/55a5699e1a28ab39638b45ed/html5/thumbnails/62.jpg)
Teaching Assistant
• Randomly select a present student