Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Intro to Programming & Algorithm Design Overview Copyright 2014 by Janson Industries Assg1Assg1 Assg2Assg2.

Similar presentations


Presentation on theme: "1 Intro to Programming & Algorithm Design Overview Copyright 2014 by Janson Industries Assg1Assg1 Assg2Assg2."— Presentation transcript:

1 1 Intro to Programming & Algorithm Design Overview Copyright 2014 by Janson Industries Assg1Assg1 Assg2Assg2

2 Copyright 2014 by Janson Industries 2 Objectives ▀ Explain ♦ Steps to creating a program ♦ External Design ♦ Flowcharts and pseudocode ♦ SFC and Raptor

3 Copyright 2014 by Janson Industries 3 External Design ▀ A visual representation of a program's user interface (UI) ▀ UIs take two general forms ♦ Graphical User Interfaces (GUIs) ♦ Command Line Interfaces (CLIs) ▀ One of the first steps for the programmer is to design the UI

4 Copyright 2014 by Janson Industries 4 External Design ▀ For example, if a program is supposed to display a Sales Transaction input screen with: ♦ The employee name ♦ Current date ♦ Current time ♦ Areas to enter multiple item names and quantities ▀ The XD would be something like this…

5 Copyright 2014 by Janson Industries External Design Tools ▀ Input screen/web page mockup Sales Transaction Employee: ###### Date: mm/dd/yyyyTime: hh/mm ItemQty More itemsFinish 5

6 Copyright 2014 by Janson Industries 6 External Design ▀ If a program is supposed to receive cost and amount from the user for a sales transaction (via the command line) and display the total cost, then the XD would look like this: What is cost of the item? 999.99 How many items are being purchased? 999 The total for the transaction is $999,999.99

7 Copyright 2014 by Janson Industries External Design Tools ▀ If a program reads or writes to a data file then a file layout/definition is part of the XD File name: Transaction Field Name Data TypeComments Transaction NumberString15 characters Item NumberNumeric8 digit integer Quantity SoldNumeric4 digit integerDate Begin TimeTime End TimeTime Employee NumberString8 characters 7

8 Copyright 2014 by Janson Industries External Design Tools ▀ If the program generates a report, a report “mock up” should be part of the XD Employee Sales Evaluation Report Date Range From: mm/dd/yyyy To: mm/dd/yyyy Employee NameTotal Sales Avg Tx Sale Avg Tx Time Xxxxxx, Xxxxxx$99,999.99 $9,999.99 hh:mm 8

9 Copyright 2014 by Janson Industries Internal Design ▀ What the heck is an Algorithm? ♦ A sequence of instructions that is an effective method for solving a problem ▀ Before a program is written, an algorithm is developed ▀ The algorithm describes the steps the program must follow to produce the correct results/output 9

10 Copyright 2014 by Janson Industries Internal Design ▀ Algorithm specified with text then refined into either ♦ Flowchart ♦ Pseudocode ▀ Flowchart is a diagram ▀ Pseudocode uses a subset of English words and indentation 10

11 Copyright 2014 by Janson Industries 11 Programming Environment ▀ When designing, use tools to generate flowcharts and pseudo code ♦ SFC and Raptor for flowcharts ▀ When programming use an IDE ♦ At a minimum an IDE will have a source code editor ► A source code editor is to a program what word processing software is to a document

12 Copyright 2014 by Janson Industries 12 Notepad++ is an example of a basic editor Let’s a programmer enter, change and save source code

13 Copyright 2014 by Janson Industries 13 External Design ▀ Say we wanted a program to ask for the users name and then display the message “Hi” followed by the users name ▀ The input and output (i.e. the external design) of the program would look like this: What is your name? Joe Hi Joe Program displays User Enters

14 Copyright 2014 by Janson Industries 14 Pseudo Code ▀ Structured English ♦ Limited set of words used consistently throughout the design ♦ Indentation used to indicate selection and iteration ► More on those later

15 Copyright 2014 by Janson Industries 15 Pseudo Code ▀ The pseudocode to define what the program has to do would be Display “What is your name?” Input name msg = “Hi ”, name Display msg

16 Copyright 2014 by Janson Industries 16 Pseudo Code ▀ Notice several standards within the pseudo code ♦ Commands begin with a capital letter ► Makes them easy to distinguish ♦ Same commands used consistently ► We don’t use: Show msg or Print msg ♦ Static text enclosed in double quotes

17 Copyright 2014 by Janson Industries 17 Pseudo Code ▀ By following standards, the pseudocode is ♦ Easier to understand ► Consistency makes things easier to recognize In real world, traffic light always has –Red light on top –Green light on bottom ♦ Created faster ► Designer doesn’t have to think up words/commands to use

18 Copyright 2014 by Janson Industries 18 Flow Charts (FC) ▀ Are internal design diagrams that use ♦ Symbols/Shapes to represent the type of operation to be preformed ► Sequential process ► Input/output ► Decision ♦ Text that further defines the exact operation to be performed ♦ Arrows to show the order in which the operations must be performed

19 Copyright 2014 by Janson Industries 19 Flow Charts (FC) ▀ Begin and end with an oval with the text Start and Stop Start Stop Other symbols

20 Copyright 2014 by Janson Industries 20 Flow Charts (FC) ▀ Input and output operations indicated with a parallelogram ▀ Sequential processes indicated with a rectangle Display “What’s your name?” msg = “Hi ”, name

21 Copyright 2014 by Janson Industries 21 Flow Charts (FC) ▀ So the FC to define the program would be: Display “What’s your name?” Input name msg = “Hi ”, name Display msg Start Stop

22 Copyright 2014 by Janson Industries 22 Flow Chart Tools ▀ Help the designer generate the diagrams ♦ GUI to drag and drop symbols ♦ Automatically generate start/stop symbols ♦ Based on FC, may create pseudo code

23 Copyright 2014 by Janson Industries 23 Flow Chart Tools ▀ Structured Flow Chart editor (SFC) is free software to create and modify flow charts ♦ Download from class site to your thumb drive ▀ Raptor is a flow chart editor and executer. Install from ♦ Disk with book ♦ Or http://raptor.martincarlisle.com/

24 Copyright 2014 by Janson Industries 24 Scroll to the bottom, click the software file name Software SFC

25 Copyright 2014 by Janson Industries 25 Click the Save drop down arrow & click Save As

26 Copyright 2014 by Janson Industries 26 If browser won’t let you download, use a different browser (Firefox, Chrome, Safari, etc.)

27 Copyright 2014 by Janson Industries 27 If given the option, specify thumb drive Other wise, download to default location and copy to thumb drive

28 Copyright 2014 by Janson Industries 28 Save the user guide and review User Guide

29 Copyright 2014 by Janson Industries 29 On thumb drive, double click SFC.exe file to run

30 Copyright 2014 by Janson Industries 30 Click Run

31 Copyright 2014 by Janson Industries 31 Welcome window displayed Click OK button

32 Copyright 2014 by Janson Industries 32 Click File, New and enter a title for diagram (Example), your name, click OK

33 Copyright 2014 by Janson Industries 33 Lots of options This is where the flowchart is defined and displayed This is where the pseudocode is displayed

34 Copyright 2014 by Janson Industries 34 To insert into diagram, click on location (a circle between symbols) to insert then, Edit, Insert

35 Copyright 2014 by Janson Industries 35 ] ]

36 Copyright 2014 by Janson Industries 36 Here’s a link to a video (6 mins) on using SFC https://skydrive.live.com/?cid=23EFFD5EE4558A5C&id=23EFFD5EE4558A5C%211 04&sc=documents%2F#cid=23EFFD5EE4558A5C&id=23EFFD5EE4558A5C%21430 &sc=documents%2F Often further options You must be consistent!

37 Copyright 2014 by Janson Industries 37 Non-graded Assg 1 ▀ Create the flowchart on the left using SFC and call it Name ▀ Send Name.sfc to me as an email attachment (rjanson@fscj.edu) ♦ Identify the topic as Ch1Assg1 ♦ Make sure your name is the FC author Display “What’s your name?” Input name msg = “Hi ”, name Display msg

38 Copyright 2014 by Janson Industries 38 Two Types of User Interfaces ▀ Graphical User Interfaces (GUI) ♦ Which you are all familiar with ♦ Use mouse to tell program what to do ► Click buttons, choose list options, enter data into text boxes ▀ Command Line Interface (CLI) ♦ Enter English-like commands and data to tell the computer to do stuff

39 Copyright 2014 by Janson Industries 39 Windows Command Prompt Run the application program Enter info at command prompt, press the Enter key Program displays the result

40 Copyright 2014 by Janson Industries 40 GUI Input Run the program Enter info, click Calc button Program displays the result

41 Copyright 2014 by Janson Industries 41 Raptor ▀ Flow charting tool (like SFC) ▀ Except, it let’s you execute/run the flow chart ♦ Can input data and see the results of processing ♦ Generating a GUI is very easy with Raptor

42 Copyright 2014 by Janson Industries 42 Raptor ▀ For example, here’s a Raptor FC that adds two numbers

43 Copyright 2014 by Janson Industries 43 Raptor ▀ When executed result is:

44 Copyright 2014 by Janson Industries 44 http://raptor.martincarlisle.com/

45 Copyright 2014 by Janson Industries 45 Scroll down

46 Copyright 2014 by Janson Industries 46 Click drop down button, select Save As, then specify your thumb drive Click Save

47 Copyright 2014 by Janson Industries 47 Double click to start install

48 Copyright 2014 by Janson Industries 48

49 Copyright 2014 by Janson Industries 49

50 Copyright 2014 by Janson Industries 50 Specify thumb drive location (this way you can run from any computer)

51 Copyright 2014 by Janson Industries 51

52 Copyright 2014 by Janson Industries 52

53 Copyright 2014 by Janson Industries 53 To run, double click raptor.exe

54 Copyright 2014 by Janson Industries 54 Or from the Program menu select Raptor

55 Copyright 2014 by Janson Industries 55 This is where the flowchart is defined Output shown here

56 Copyright 2014 by Janson Industries 56 To add a symbol, click to select… Raptor

57 Copyright 2014 by Janson Industries 57 … then click in flowchart where to put the symbol You can also drag/drop Raptor

58 Copyright 2014 by Janson Industries 58 To edit symbol (add function) click symbol… Raptor

59 Copyright 2014 by Janson Industries 59 Then click Edit and Edit Selection Raptor

60 Copyright 2014 by Janson Industries 60 Enter statement(s), click done Raptor

61 Copyright 2014 by Janson Industries 61 To run, click the Execute to Completion button Raptor

62 Copyright 2014 by Janson Industries 62 Raptor Output displayed in Console

63 Copyright 2014 by Janson Industries 63 Raptor ▀ Raptor has two symbols for I/O ♦ One for input ♦ One for output ▀ The input symbol actually does an output first ♦ A text prompt is displayed ♦ Then the input is done

64 Copyright 2014 by Janson Industries 64 Raptor Can also just double click the symbol to edit

65 Copyright 2014 by Janson Industries 65 Raptor Enter prompt text, variable to hold info, click Done

66 Copyright 2014 by Janson Industries 66 Added an output symbol Raptor

67 Copyright 2014 by Janson Industries 67 As each symbol is executed, it’s outlined in green Raptor

68 Copyright 2014 by Janson Industries 68 When input symbol reached, program execution halts and a window is displayed with the prompt text and an input field Raptor

69 Copyright 2014 by Janson Industries 69 User should enter the input and click OK Raptor

70 Copyright 2014 by Janson Industries 70 Raptor Program finishes executing and results displayed in console

71 Copyright 2014 by Janson Industries 71 Non-graded Assg 2 ▀ Create the flowchart on the left using Raptor and call it Name ▀ Send Name.rap file to me as an email attachment (rjanson@fscj.edu) ♦ Identify the topic as Ch1Assg2 “What's your name?” GET name msg “Hi ” + name PUT msg

72 Copyright 2014 by Janson Industries 72 Non-graded Assg 2 ▀ So when the program is run a window should be displayed with the text "What is your name" ▀ If the name "John" is entered and the OK button is pressed ♦ The text "Hi John" will be displayed in the MasterConsole

73 Copyright 2014 by Janson Industries 73 Points to Remember ▀ Algorithm ♦ Set of instructions to solve a problem ▀ Flowchart: ♦ Diagram representation of an algorithm ▀ Pseudo code: ♦ Word representation of an algorithm ▀ Lots of tools to help generate


Download ppt "1 Intro to Programming & Algorithm Design Overview Copyright 2014 by Janson Industries Assg1Assg1 Assg2Assg2."

Similar presentations


Ads by Google