Intro to Programming Algorithm Design Overview Assg 1

  • Slides: 42
Download presentation
Intro to Programming & Algorithm Design Overview Assg 1 1 Copyright 2017 by Janson

Intro to Programming & Algorithm Design Overview Assg 1 1 Copyright 2017 by Janson Industries

Objectives ▀ Explain ♦ Steps to creating a program ♦ External Design ♦ Flowcharts

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

External Design ▀ ▀ ▀ Copyright 2017 by Janson Industries A visual representation of

External Design ▀ ▀ ▀ Copyright 2017 by Janson Industries 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 3

External Design ▀ ▀ Copyright 2017 by Janson Industries For example, if a program

External Design ▀ ▀ Copyright 2017 by Janson Industries 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… 4

External Design Tools ▀ Input screen/web page mockup Sales Transaction Employee: ###### Date: mm/dd/yyyy

External Design Tools ▀ Input screen/web page mockup Sales Transaction Employee: ###### Date: mm/dd/yyyy Time: hh/mm Item Copyright 2017 by Janson Industries Qty More items Finish 5

External Design ▀ If a program is supposed to receive cost and amount from

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 Copyright 2017 by Janson Industries 6

External Design Tools ▀ If a program reads or writes to a data file

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 Type Transaction Number String Item Number Numeric Quantity Sold Numeric Date Begin Time End Time Employee Number String Copyright 2017 by Janson Industries Comments 15 characters 8 digit integer 4 digit integer 8 characters 7

External Design Tools ▀ If the program generates a report, a report “mock up”

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 Name Xxxxxx, Xxxxxx Total Sales $99, 999. 99 Avg Tx Sale Avg Tx Time $9, 999. 99 hh: mm 8 Copyright 2017 by Janson Industries

Internal Design ▀ What the heck is an Algorithm? ♦ ▀ ▀ A sequence

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 Copyright 2017 by Janson Industries

Internal Design ▀ ▀ ▀ Algorithm specified with text then refined into either ♦

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 Copyright 2017 by Janson Industries

Programming Environment ▀ When designing, use tools to generate flowcharts and pseudo code ♦

Programming Environment ▀ When designing, use tools to generate flowcharts and pseudo code ♦ ▀ SFC, Flowgorithm, and Raptor 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 Copyright 2017 by Janson Industries 11

Notepad++ is an example of a basic editor Let’s a programmer enter, change and

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

New Example - External Design ▀ ▀ Say we wanted a program to ask

New Example - 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: Program displays User Enters Program displays Copyright 2017 by Janson Industries What is your name? Joe Hi Joe 13

Algorithm ▀ The algorithm for the program would be 1. Prompt the user for

Algorithm ▀ The algorithm for the program would be 1. Prompt the user for their name 2. Read in the name 3. Display the text "Hi" and the user's name 14 Copyright 2017 by Janson Industries

Pseudo Code ▀ aka Structured English is an internal design that uses ♦ A

Pseudo Code ▀ aka Structured English is an internal design that uses ♦ A limited set of words consistently throughout the design ♦ Indentation to indicate selection and iteration ► More ♦ on those later Goes into greater detail than the algorithm 15 Copyright 2017 by Janson Industries

Pseudo Code ▀ The pseudocode to define what the program has to do would

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 2017 by Janson Industries

Pseudo Code ▀ Notice several standards within the pseudo code ♦ Commands (Display, Input)

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

Pseudo Code ▀ By following standards, the pseudocode is ♦ Easier to understand ►

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 2017 by Janson Industries

Flow Charts (FC) ▀ Are internal design diagrams that use ♦ Symbols/Shapes to represent

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 2017 by Janson Industries

Flow Charts (FC) ▀ Begin and end with an oval with the text Start

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

Flow Charts (FC) ▀ Input and output operations indicated with a parallelogram Display “What’s

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

Flow Charts (FC) ▀ So the FC to define the program would be: Start

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

Flow Chart Tools ▀ Help the designer generate the diagrams ♦ GUI to drag

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 or source code 23 Copyright 2017 by Janson Industries

Flow Chart Tools ▀ Structured Flow Chart editor (SFC) is free software to create

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 Flowgorithm and Raptor are flow chart editors and executers 24 Copyright 2017 by Janson Industries

Due to system changes please go to the assignment area in Blackboard for this

Due to system changes please go to the assignment area in Blackboard for this file or any other files you cannot download from the class website Scroll to the bottom, click the software file name Software 25 Copyright 2017 by Janson Industries

Click the Save drop down arrow & click Save As 26 Copyright 2017 by

Click the Save drop down arrow & click Save As 26 Copyright 2017 by Janson Industries

If browser won’t let you download, use a different browser (Firefox, Chrome, Safari, etc.

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

If given the option, specify thumb drive Other wise, download to default location and

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

Save the user guide and review User Guide 29 Copyright 2017 by Janson Industries

Save the user guide and review User Guide 29 Copyright 2017 by Janson Industries

On thumb drive, double click SFC. exe file to run 30 Copyright 2017 by

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

If needed, click Run 31 Copyright 2017 by Janson Industries

If needed, click Run 31 Copyright 2017 by Janson Industries

Welcome window displayed Click OK button Copyright 2017 by Janson Industries 32

Welcome window displayed Click OK button Copyright 2017 by Janson Industries 32

Click File, New and enter a title for diagram (Example), your name, click OK

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

Lots of options This is where the flowchart is defined and displayed This is

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

To insert into diagram, click on location (a circle between symbols) to insert then,

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

] ] 36 Copyright 2017 by Janson Industries

] ] 36 Copyright 2017 by Janson Industries

Often further options You must be consistent! Here’s a link to a video (6

Often further options You must be consistent! Here’s a link to a video (6 mins) on using SFC http: //web. fscj. edu/Janson/COP 1000/First. Program. mov 37 Copyright 2017 by Janson Industries

Non-graded Assg 1 Display “What’s your name? ” Input name msg = “Hi ”,

Non-graded Assg 1 Display “What’s your name? ” Input name msg = “Hi ”, name Display msg Copyright 2017 by Janson Industries ▀ ▀ 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 Ch 1 Assg 1 Make sure your name is the FC author 38

Two Types of User Interfaces ▀ Graphical User Interfaces (GUI) ♦ ♦ Which you

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 2017 by Janson Industries

Windows Command Prompt Run the application program (java Oil. Calc) Enter info at command

Windows Command Prompt Run the application program (java Oil. Calc) Enter info at command prompt (250), press the Enter key Program displays the result 40 Copyright 2017 by Janson Industries

GUI Input Run the program Enter info, click Calc button Program displays the result

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

Points to Remember ▀ External Design ♦ ▀ Algorithm ♦ ▀ Diagram representation of

Points to Remember ▀ External Design ♦ ▀ Algorithm ♦ ▀ Diagram representation of an algorithm Pseudo code: ♦ ▀ Set of instructions to solve a problem Flowchart: ♦ ▀ Picture/sketch of the UI (User Interface) Text representation of an algorithm Lots of tools to help generate 42 Copyright 2017 by Janson Industries