Input - Process - Output       in VB.NET                           1
ObjectivesDistinguish between logic and syntaxUnderstand and use the input statementUnderstand and use the assignmentstate...
Logic and SyntaxA computer program is a solution to aproblem.An algorithm is the logical design used toaccomplish a specif...
Input Statements                   4
Input StatementsAn input statement accepts data from theuser and stores that data into a variable.A variable is a storage ...
Declaring VariablesVariables are declared with the Dimstatement (short for Dimension statement).One or more variables can ...
Naming Rules for Variables A variable must have a unique name, called an identifier. Identifiers must follow three rules: ...
Working with ConstantsA constant is a storage location whosevalue cannot change during the executionof the program.Constan...
Data TypeData Type           DescriptionString              TextByte (1 byte)       Positive Whole Number (0 to 255)Short ...
Weekly Paycheck ProgramThe weeklypaycheck programhas two inputvariables:Hours and Rate                          10
Operators and ExpressionsAn operator is a symbol that indicates anaction to be performed.Value-returning code elements suc...
Assignment StatementsThe assignmentstatement can be usedto perform acalculation and storethe result.An expression is avalu...
The Assignment StatementAn assignment statement is used to store avalue into a variable or an object property. variable =...
Numbers and String Operators  Arithmetic operators require numeric  operands and produce numeric results.  The string oper...
Numerical OperatorsOperation    Operator      Expression 1   Result 1   Expression 2   Result 2Plus &               +     ...
How to Write Formulas                        16
Output Statements   (flow chart)                    17
Intrinsic FunctionsVB .NET provides a large number ofintrinsic functions to improve developerproductivity.Intrinsic functi...
Common Functions        Intrinsic functions are predefined commands that        provide developers with common functions.F...
Rnd StatementThe Rnd statement generates a singleprecision random value between 0.0 upto (but not including) 1.0.The Rando...
Financial FunctionsPmt is a function for determining monthlypayments. Pmt(Rate, NPer, PV)FV is a function for determining...
SummaryVariables are storage locations used for holding inputand processing information. Each variable has two components...
SummaryExpressions are combinations of operators andvalue-returning code elements such as variables,constants, and literal...
Upcoming SlideShare
Loading in...5
×

Input output

321

Published on

Intro to programming concepts

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
321
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Input output

  1. 1. Input - Process - Output in VB.NET 1
  2. 2. ObjectivesDistinguish between logic and syntaxUnderstand and use the input statementUnderstand and use the assignmentstatementUnderstand and use the output statementUnderstand and use arithmetic operatorswith precedenceSuccessfully write program solutions thatrequire input, processing, and output 2
  3. 3. Logic and SyntaxA computer program is a solution to aproblem.An algorithm is the logical design used toaccomplish a specific objective.Syntax refers to the specific rules of aprogramming language. 3
  4. 4. Input Statements 4
  5. 5. Input StatementsAn input statement accepts data from theuser and stores that data into a variable.A variable is a storage location that can beaccessed and changed by developer code.A variable has a name and an associateddata value.A variable has a data type that determinesthe kind of data values the variable canstore. 5
  6. 6. Declaring VariablesVariables are declared with the Dimstatement (short for Dimension statement).One or more variables can be declared witha single Dim statement.The Dim statement can be used to specifythe variable’s initial value by placing anequal sign after the data type. 6
  7. 7. Naming Rules for Variables A variable must have a unique name, called an identifier. Identifiers must follow three rules:  Begin with a letter or underscore  Contain only letters, digits, and underscores  Cannot be reserved wordsDim identifier [, identifier] [As datatype [= initialvalue]] 7
  8. 8. Working with ConstantsA constant is a storage location whosevalue cannot change during the executionof the program.Constants are declared with the Constdeclaration. Const identifier As datatype = value 8
  9. 9. Data TypeData Type DescriptionString TextByte (1 byte) Positive Whole Number (0 to 255)Short (2 bytes) Whole Number (-32,768 to 32,767)Integer (4 bytes) Whole Number (+ or – up to 2 million)Long (8 bytes) Whole Number (huge!)Single (4 bytes) Floating point (+ or – up to 3.4 x 1038)Double (8 bytes) Floating point (+ or – up to 1.8 x 10308)Decimal Stored exactly as BCD (currency & percentages)Date Also stores timeBoolean True or falseChar Single character or positive number (up to 65535) 9
  10. 10. Weekly Paycheck ProgramThe weeklypaycheck programhas two inputvariables:Hours and Rate 10
  11. 11. Operators and ExpressionsAn operator is a symbol that indicates anaction to be performed.Value-returning code elements such asvariables, constants, and expressions can becombined with one or more operators toform an expression. 11
  12. 12. Assignment StatementsThe assignmentstatement can be usedto perform acalculation and storethe result.An expression is avalue-returning codeelement, such as avariable ormathematical formula. 12
  13. 13. The Assignment StatementAn assignment statement is used to store avalue into a variable or an object property. variable = expression object.property = expressionThe equal sign (=) is the assignmentoperator. 13
  14. 14. Numbers and String Operators Arithmetic operators require numeric operands and produce numeric results. The string operator concatenation (&) requires String operands and produces a String result such as:  S = “sun” & “set”  S becomes “sunset” 14
  15. 15. Numerical OperatorsOperation Operator Expression 1 Result 1 Expression 2 Result 2Plus & + – 4–5+2 1 4 – (5 + 2) -3MinusMultiply & * / 1+3*7 22 17 / 3 5.667DivideInteger 12 4 3 17 3 5DivisionInteger Mod 12 Mod 4 0 17 Mod 3 2RemainderExponent ^ 5^2+1 26 5 ^ (2 + 1) 125(Power of) 15
  16. 16. How to Write Formulas 16
  17. 17. Output Statements (flow chart) 17
  18. 18. Intrinsic FunctionsVB .NET provides a large number ofintrinsic functions to improve developerproductivity.Intrinsic functions support a broad range ofactivities, including math calculations,business calculations, time and datefunctions, string formatting functions, andmany more. 18
  19. 19. Common Functions Intrinsic functions are predefined commands that provide developers with common functions.Function Example 1 Result 1 Example 2 Result 2Val() (“23.5”) 23.5 (“£32”) 0IsNumeric() (“23.5”) True (“£32”) TrueFormatCurrency() (1234.567) £1,234.57 (4.5) £4.50Format(expr,str) (1/2, “0.##”) “0.5” (6.666, “0.###”) “6.67”Int() (3.8) 3 Int(Rnd()) 0 Double value IntegerRnd() () Int(Rnd()*6)+1 between 0 and 1 from 1 to 6Abs() (-3.3) 3.3 (5.67) 5.67Import System.Math 19
  20. 20. Rnd StatementThe Rnd statement generates a singleprecision random value between 0.0 upto (but not including) 1.0.The Randomize statement is used tochange the seed value (randomsequence). 20
  21. 21. Financial FunctionsPmt is a function for determining monthlypayments. Pmt(Rate, NPer, PV)FV is a function for determining the futurevalue of an annuity based on periodic, fixedpayments and a fixed interest rate. FV(Rate, NPer, Pmt) 21
  22. 22. SummaryVariables are storage locations used for holding inputand processing information. Each variable has two components: its name and its value. It is good practice to make variable names descriptive with mixed case. The Dim statement is used to declare a variable by specifying its name and data type.Input statements are used to get data into variables.Assignment statements are used to performcalculations and store the result. 22
  23. 23. SummaryExpressions are combinations of operators andvalue-returning code elements such as variables,constants, and literals. One of the common uses of an expression is to perform a calculation for an assignment statement. Intrinsic functions provide pre-defined methods for common processing requirements.Output statements are used to displayinformation.Input, assignment, and output statements aresufficient to write small programs. 23
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×