VB.Net Programming Console Application

Slides:



Advertisements
Similar presentations
Dry Run You can test your program without using a computer by dry running it on paper You act as the computer – following the instructions of the program,
Advertisements

P1PMF Split1 QBASIC. P1PMF Split2QBasic Command Prompt Will launch the emulator DOS operating system? Press Alt + Enter to display the widescreen.
30/04/ Selection Nested If structures & Complex Multiple Conditions.
Programming by Example Version 1.0. Objectives Take a small computing problem, and walk through the process of developing a solution. Investigate the.
CP Week 4 Making Decisions. CP1020 ©University of Wolverhampton - Ian Coulson & Steve Garner Decisions Example: Driving to a lecture you notice.
 2002 Prentice Hall. All rights reserved. 1 Chapter 4: Control Structures: Part 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures.
CS1061 C Programming Lecture 5: Building Blocks of Simple Programs A. O’Riordan, 2004.
Control Structures: Part 1. Introduction Control Structures If / Then Selection Structure If / Then / Else Selection Structure While Repetition Structure.
What is the out put #include using namespace std; void main() { int i; for(i=1;i
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Creating Embedded Formative Assessment Dr. Steve Broskoske Misericordia University EDU 533 Computer-based Education.
Chapter 4 The If…Then Statement
1 2.2 Selection Logical Operators. 2 Learning Objectives Explain how the logical operator AND Boolean statements works.
 2002 Prentice Hall. All rights reserved. 1 Chapter 4: Control Structures: Part 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures.
26/10/ Selection Nested If structures & Complex Multiple Conditions.
Statements That Repeat. For...Next Loop Structure For counter = start To end Step increment statements Next counter Where Counter is tested to see if.
4.1 Introduction Structured programming –Control structures Helpful in building and manipulating objects BZUPAGES.COM.
Introduction to VB.NET 2005 Dr. McDaniel IDS4704 Spring 2005.
Unit 2 – Algorithms & Pseudocode. Algorithms Computer problems solved by executing series of action in order Procedure –The Actions to execute –The Order.
ASP-5-1 ASP Control Structures Colorado Technical University IT420 Tim Peterson.
22/11/ Selection If selection construct.
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.
Chapter 3 Control Structures. The If…Then Statement The If…Then statement is a Decision statement = that executes a set of statements when a condition.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
Pay Example (PFirst98) Please use speaker notes for additional information!
31/01/ Selection If selection construct.
Controlling Program Flow with Decision Structures.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Loop and repetition. Today Passing values to and back from Sub procedures Option Buttons Do While Loops For Loops Population Growth.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 11 So Many Paths … So Little Time.
 2003 Prentice Hall, Inc. All rights reserved. 1 Basic C++ Programming.
Visual Basic Declaring Variables Dim x as Integer = 0 In the statement above, x is being declared as an Integer (whole number) and is initialised.
Selection Using IF THEN ELSE CASE Introducing Loops.
Slide 1 Chapter 4 The If…Then Statement  Conditional control structure, also called a decision structure  Executes a set of statements when a condition.
© 2006 Lawrenceville Press Slide 1 Chapter 5 The If…Then Statement (One-Way)  Conditional control structure, also called a decision structure  Executes.
Visual Basic Fundamental Concepts
A variable is a name for a value stored in memory.
Chapter 4 The If…Then Statement
Visual Basic I Programming
Visual Basic 6 (VB6) Data Types, And Operators
IF statements.
Chapter 4: Control Structures
Chapter 4 – Control Structures Part 1
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
When I want to execute the subroutine I just give the command Write()
Visual Basic..
Chapter 2 - Introduction to C Programming
Use proper case (ie Caps for the beginnings of words)
Chapter 2 - Introduction to C Programming
Chapter 3: Introduction to Problem Solving and Control Statements
PC01 Term 3 Project Snake. PC01 Term 3 Project Snake.
If selection construct
3 Control Statements:.
VB.Net Programming Console Application
VB.Net Programming Console Application
If selection construct
Introduction to Problem Solving and Control Statements
Chapter 2 - Introduction to C Programming
Additional Topics in VB.NET
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Procedures: Functions and Subroutines
Programming Concepts and Database
Python Basics with Jupyter Notebook
Chapter 2 - Introduction to C Programming
VB.Net Programming Console Application
CS 1111 Introduction to Programming Spring 2019
Presentation transcript:

VB.Net Programming Console Application Walkthrough Example : Student Grades

Narrative Memory Screen Code The first line of the program indicates the main( ) procedure. Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If End While Console.ReadKey() End Sub Code Narrative Memory Screen

Narrative Memory Screen Code This line is a comment. Comment lines are for information only. They are ignored by the compiler. Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If End While Console.ReadKey() End Sub Code Narrative Memory Screen

Code Narrative Memory Screen 80 60 40 DIST MERIT PASS These three lines create three CONSTANTS and name them DIST, MERIT and PASS. CONSTANT means the value will not change during the program. Values are set now and can not be changed. Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40

Code Narrative Memory Screen 80 60 40 DIST MERIT PASS Mark A variable is created called Mark. This will store the student mark when entered by the user. Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark

Code Narrative Memory Screen 80 60 40 DIST MERIT PASS Mark This line Clears the console screen. Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark

Code Narrative Memory Screen 80 60 40 DIST MERIT PASS Mark This line displays a prompt for the user to enter a student mark. Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark Please enter the first mark :

Code Narrative Memory Screen 80 60 40 35 DIST MERIT PASS Mark The user enters a mark and it is stored in the memory variable Mark. Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark 35 Please enter the first mark : 35

Code Narrative Memory Screen 80 60 40 35 DIST MERIT PASS Mark The while loop starts. All code between while and end while is in the loop. The loop will continue while the value in Mark is greater than or equal to 0. Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark 35 Please enter the first mark : 35

Code Narrative Memory Screen 80 60 40 35 DIST MERIT PASS Mark This statement checks the variable Mark is greater than or equal to the constant DIST. If it is then the text in quotes is printed to the console. If it is not then the next ElseIF is run…… Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark 35 Please enter the first mark : 35

Code Narrative Memory Screen 80 60 40 35 DIST MERIT PASS Mark This statement checks the variable Mark is between the MERIT and DIST values. If it is then the text in quotes is printed to the console. If it is not then the next ElseIF is run…… Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark 35 Please enter the first mark : 35

Code Narrative Memory Screen 80 60 40 35 DIST MERIT PASS Mark This statement checks the variable Mark is between the PASS and MERIT values. If it is then the text in quotes is printed to the console. If it is not then the Else is run…… Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark 35 Please enter the first mark : 35

Code Narrative Memory Screen 80 60 40 35 DIST MERIT PASS Mark If the code has reached this else and not found that the mark entered is a distinction, merit or pass then it must be a fail. The text in quotes is printed to the console. Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark 35 Please enter the first mark : 35 Fail

Code Narrative Memory Screen 80 60 40 35 DIST MERIT PASS Mark The nested if statements end here. . Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark 35 Please enter the first mark : 35 Fail

Code Narrative Memory Screen 80 60 40 35 DIST MERIT PASS Mark The prompt for the next grade is displayed. . Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If Console.Write("Please enter the next mark :") End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark 35 Please enter the first mark : 35 Fail Please enter the next mark :

Code Narrative Memory Screen 80 60 40 -1 DIST MERIT PASS Mark The user enters the next mark and it is stored in the memory variable mark. Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If Console.Write("Please enter the next mark :") End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark -1 Please enter the first mark : 35 Fail Please enter the next mark : -1

Code Narrative Memory Screen 80 60 40 -1 DIST MERIT PASS Mark This is the end of the while loop ….but the program loops back the question at the head of the loop to check the value in the memory variable Mark to decide when to finish looping. Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If Console.Write("Please enter the next mark :") End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark -1 Please enter the first mark : 35 Fail Please enter the next mark : -1

Code Narrative Memory Screen 80 60 40 -1 DIST MERIT PASS Mark The loop will continue while the value in the memory variable Mark is greater than or equal to 0. Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If Console.Write("Please enter the next mark :") End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark -1 Please enter the first mark : 35 Fail Please enter the next mark : -1

Code Narrative Memory Screen 80 60 40 -1 DIST MERIT PASS Mark The loop will continue while the value in the memory variable Mark is greater than or equal to 0.. .. .. .. the value in Mark is less than 0 so the loop ends. Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If Console.Write("Please enter the next mark :") End While Console.ReadKey() End Sub Code Narrative Memory Screen DIST 80 MERIT PASS 60 40 Mark -1 Please enter the first mark : 35 Fail Please enter the next mark : -1

Narrative Memory 80 60 40 -1 Screen Code DIST MERIT PASS Mark This line waits for the user to press a key before ending the program. DIST MERIT PASS Mark 80 60 40 -1 Screen Code Sub Main() 'This program demonstrates the use of IF…THEN…Else Const DIST = 80 Const MERIT = 60 Const PASS = 40 'Variables Dim Mark As Integer Console.Clear() Console.Write("Please enter the first mark :") Mark = Console.ReadLine() While Mark >= 0 If Mark >= DIST Then Console.WriteLine("Distinction") ElseIf Mark >= MERIT And Mark < DIST Then Console.WriteLine("Merit") ElseIf Mark >= PASS And Mark < MERIT Then Console.WriteLine("Pass") Else Console.WriteLine("Fail") End If Console.Write("Please enter the next mark :") End While Console.ReadKey() End Sub Please enter the first mark : 35 Fail Please enter the next mark : -1