1 / 16

Software Development

Software Development. Topic 3 - High Level Programming Language Constructs.

devin-orr
Download Presentation

Software Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Software Development Topic 3 - High Level Programming Language Constructs

  2. Describe and give examples of the following constructs in an appropriate HLL:Input and Output Assignment;Arithmetical Operations and Logical operators;Fixed Loop;Conditional Loops;Simple and Complex Conditions;Conditional Statements; &Nested Loops. TOPIC 3 - High Level Programming Language Constructs

  3. Input and Output Assignmet: • I would like to write a program that would ask a user to enter their name and their age. It will then display both of these: • On mouseUp • Local varName, varAge • Ask “Please enter your name” • Put it into varName • Ask “Please enter your age” • Put it into varAge • Put “Your name is “ varName into field “fieldName” • Put “Your age is “ varAge into field “fieldAge” • End mouseUp (Notice that we only change the keyword from name to age. This is the same in all programs. varName and var Age are the pieces of code you would change in other programs.) Input Output

  4. Arithmetical Operations • I would like to write a program that will calculate the total money raised from a sponsored run. • On mouseUp • Local varLaps, varAmountPerLap, varTotalRaised • Ask “Please enter the number of laps” • Put it into varLaps • Ask “Please enter the amount per lap” • Put it into varAmountPerLap • Put varlaps * varAmountPerLap into varTotalRaised • Put “The total raised is “ varTotalRaised into field “fieldTotal” • End mouseUp (Notice the order IPO – Always! When we do the process we do the calculation first, then put it in the variable. + = add, -= minus, *= times, / = Divide) Input Process Output

  5. Logical Operators • Logical operators are your “And” and “Or”. • Lets look at your practice coursework program! • If MembersAge >= 9 AND MembersAge <= 14 then • Put “J” into MemberType • Else IF MembersAge > 14 and MembersAge < 18 then • Put “I” into MemberType • Else • Put “S” into MemberType • End If • When an AND is used both conditions must be met.

  6. Logical Operators • When an OR is used either of the conditions must be met. • If VarAge <= 16 or VarAge >=60 then • Put “ConcessionPass” into varBusTicket • Else • Put “StandardPass” into varBusTicket • End If

  7. Fixed Loops • A fixed loop is one that repeats for a set number of times. E.g. • Repeat 3 times • Put “Hello” after field “DisplayMessage” • End Repeat • The above program will display the work “Hello” in the field “DisplayMessage” 3 times.

  8. Conditional Loops • A conditional loop is one that will repeat until the user enters a certain input. This is used in input validation. • Lets look at the coursework program: • Ask “How many guests are checking out?” • Put it into varCheckOut • Repeat until varCheckOut >= 1 and varCheckOut<=10 • Beep • Ask “You have made an error! Please enter a number between 1 & 10” • Put it into varCheckOut • End Repeat This will continue Until the user meets the conditions.

  9. Simple and Complex Conditions • A simple condition is one that only has one condition that needs to be met • Put 4 into varCorrectAnswer • Ask “What is 2 + 2?” • Put it into varUserAnswer • Repeat until varUserAnswer = varCorrectAnswer • Beep • Ask “You have made a mistake. Please try again.” • Put it into varUserAnswer • End Repeat There is only one condition here.

  10. Simple and Complex Conditions • A complex condition is one that only has more than one condition that needs to be met: • Ask “How many guests are checking out?” • Put it into varCheckOut • Repeat until varCheckOut >= 1 and varCheckOut<=10 • Beep • Ask “You have made an error! Please enter a number between 1 & 10” • Put it into varCheckOut • End Repeat There are two conditions here.

  11. Conditional Statements • A conditional statement is an If statement. It follows the following syntax: • If (condition = true) Then • Action 1 • Else • Action 2 • End If • Here is part of your coursework: • If MembersAge >= 9 AND MembersAge <= 14 then • Put “J” into MemberType • Else IF MembersAge > 14 and MembersAge < 18 then • Put “I” into MemberType • Else • Put “S” into MemberType • End If

  12. Nested Loops • A nested loop is a loop within a loop. Here is part of your practice coursework that shows this: • Repeat varNoOfMembers times • Ask “Please enter your age” • Put it into varAge • Repeat Until varAge > =9 and varAge < = 24 • Beep • Ask “ You have made an error the age should be between 9 & 24. Please re-enter : “ • Put it into varAge • End repeat • End Repeat

  13. Describe and give examples of numeric and string and 1-d arrays. TOPIC 3 - High Level Programming Language Constructs

  14. Types of Data • A string data type is used to store alphanumeric data. • Local varName • Local varPhoneNumber • A numeric data type is used to store numbers. • Local varAge • Local varAverage • 1-d Arrays are used to store lists. • Local varNamesArray • Local varAgesArray

  15. Describe and give examples of pre-defined functions TOPIC 3 - High Level Programming Language Constructs

  16. Pre-defined Functions • Definition • A pre-defined function is a keyword that performs a specific task in the program without the user having to code it. • Examples: • Rnd - selects a random number • Len - counts the number of characters in a string • Sin, Cos, Tan

More Related