+ All Categories
Home > Documents > CS0004: Introduction to Programming

CS0004: Introduction to Programming

Date post: 14-Feb-2016
Category:
Upload: yehudi
View: 35 times
Download: 0 times
Share this document with a friend
Description:
CS0004: Introduction to Programming. Problem Solving and Programming Tools. Review. Machine Language. Review. Machine Language is a system of instructions and data executed directly by a computer's central processing unit . Review. - PowerPoint PPT Presentation
Popular Tags:
141
CS0004: Introduction to Programming Problem Solving and Programming Tools
Transcript
Page 1: CS0004:  Introduction to Programming

CS0004: Introduction to Programming

Problem Solving and Programming Tools

Page 2: CS0004:  Introduction to Programming

Review Machine Language

Page 3: CS0004:  Introduction to Programming

Review Machine Language is a system of instructions

and data executed directly by a computer's central processing unit.

Page 4: CS0004:  Introduction to Programming

Review Machine Language is a system of instructions

and data executed directly by a computer's central processing unit.

Higher-Level Languages

Page 5: CS0004:  Introduction to Programming

Review Machine Language is a system of instructions

and data executed directly by a computer's central processing unit.

Higher-Level Languages consists of instruction that people can understand.

Page 6: CS0004:  Introduction to Programming

Review Machine Language is a system of instructions

and data executed directly by a computer's central processing unit.

Higher-Level Languages consists of instruction that people can understand.

Event-driven programming

Page 7: CS0004:  Introduction to Programming

Review Machine Language is a system of instructions

and data executed directly by a computer's central processing unit.

Higher-Level Languages consists of instruction that people can understand.

Event-driven programming is a paradigm in which the flow of programs are determined by events.

Page 8: CS0004:  Introduction to Programming

Review Machine Language is a system of instructions

and data executed directly by a computer's central processing unit.

Higher-Level Languages consists of instruction that people can understand.

Event-driven programming is a paradigm in which the flow of programs are determined by events.

A program

Page 9: CS0004:  Introduction to Programming

Review Machine Language is a system of instructions

and data executed directly by a computer's central processing unit.

Higher-Level Languages consists of instruction that people can understand.

Event-driven programming is a paradigm in which the flow of programs are determined by events.

A program is a collection of instructions.

Page 10: CS0004:  Introduction to Programming

Review Machine Language is a system of instructions

and data executed directly by a computer's central processing unit.

Higher-Level Languages consists of instruction that people can understand.

Event-driven programming is a paradigm in which the flow of programs are determined by events.

A program is a collection of instructions. A compiler

Page 11: CS0004:  Introduction to Programming

Review Machine Language is a system of instructions

and data executed directly by a computer's central processing unit.

Higher-Level Languages consists of instruction that people can understand.

Event-driven programming is a paradigm in which the flow of programs are determined by events.

A program is a collection of instructions. A compiler is a computer program that

translates high-level language such as VB in Machine Language.

Page 12: CS0004:  Introduction to Programming

Review Machine Language is a system of instructions

and data executed directly by a computer's central processing unit.

Higher-Level Languages consists of instruction that people can understand.

Event-driven programming is a paradigm in which the flow of programs are determined by events.

A program is a collection of instructions. A compiler is a computer program that

translates high-level language such as VB in Machine Language.

Running a program

Page 13: CS0004:  Introduction to Programming

Review Machine Language is a system of instructions

and data executed directly by a computer's central processing unit.

Higher-Level Languages consists of instruction that people can understand.

Event-driven programming is a paradigm in which the flow of programs are determined by events.

A program is a collection of instructions. A compiler is a computer program that

translates high-level language such as VB in Machine Language.

Running a program is executing the instructions given a program.

Page 14: CS0004:  Introduction to Programming

Programming Languages and Problem Solving In this class we will be using Visual Basic, but

there are many things it shares with most programming languages.

Page 15: CS0004:  Introduction to Programming

Programming Languages and Problem Solving In this class we will be using Visual Basic, but

there are many things it shares with most programming languages.

Namely, 3 things:

Page 16: CS0004:  Introduction to Programming

Programming Languages and Problem Solving In this class we will be using Visual Basic, but

there are many things it shares with most programming languages.

Namely, 3 things: Takes in data

Page 17: CS0004:  Introduction to Programming

Programming Languages and Problem Solving In this class we will be using Visual Basic, but

there are many things it shares with most programming languages.

Namely, 3 things: Takes in data Manipulates the data

Page 18: CS0004:  Introduction to Programming

Programming Languages and Problem Solving In this class we will be using Visual Basic, but

there are many things it shares with most programming languages.

Namely, 3 things: Takes in data Manipulates the data Produces some information

Page 19: CS0004:  Introduction to Programming

Programming Languages and Problem Solving In this class we will be using Visual Basic, but

there are many things it shares with most programming languages.

Namely, 3 things: Takes in data Manipulates the data Produces some information

If you can break a problem down into these steps, you can create a program to solve it.

Page 20: CS0004:  Introduction to Programming

Programming Languages and Problem Solving In this class we will be using Visual Basic, but

there are many things it shares with most programming languages.

Namely, 3 things: Takes in data Manipulates the data Produces some information

If you can break a problem down into these steps, you can create a program to solve it.

But do we start writing code as soon as we run into a problem?

Page 21: CS0004:  Introduction to Programming

Programming Languages and Problem Solving In this class we will be using Visual Basic, but

there are many things it shares with most programming languages.

Namely, 3 things: Takes in data Manipulates the data Produces some information

If you can break a problem down into these steps, you can create a program to solve it.

But do we start writing code as soon as we run into a problem?

Answer: No.

Page 22: CS0004:  Introduction to Programming

Algorithms vs. Programs An Algorithm is

Page 23: CS0004:  Introduction to Programming

Algorithms vs. Programs An Algorithm is a step-by-step procedure

devised for the purpose of taking in data and producing the correct output.

Page 24: CS0004:  Introduction to Programming

Algorithms vs. Programs An Algorithm is a step-by-step procedure

devised for the purpose of taking in data and producing the correct output.

A program is the actual implementation of an algorithm in a programming language.

Page 25: CS0004:  Introduction to Programming

Algorithms vs. Programs An Algorithm is a step-by-step procedure

devised for the purpose of taking in data and producing the correct output.

A program is the actual implementation of an algorithm in a programming language.

Before writing a program, you must develop an algorithm to solve a problem.

Page 26: CS0004:  Introduction to Programming

Algorithms vs. Programs An Algorithm is a step-by-step procedure

devised for the purpose of taking in data and producing the correct output.

A program is the actual implementation of an algorithm in a programming language.

Before writing a program, you must develop an algorithm to solve a problem.

Very Important: It is highly recommended to think about the problem first, then develop an algorithm, then write the program.

Page 27: CS0004:  Introduction to Programming

Program Development Cycle When Developing a program in both the real

world AND in this class, there are 6 steps:

Page 28: CS0004:  Introduction to Programming

Program Development Cycle When Developing a program in both the real

world AND in this class, there are 6 steps:1) Analyze the problem

Page 29: CS0004:  Introduction to Programming

Program Development Cycle When Developing a program in both the real

world AND in this class, there are 6 steps:1) Analyze the problem2) Plan a solution

Page 30: CS0004:  Introduction to Programming

Program Development Cycle When Developing a program in both the real

world AND in this class, there are 6 steps:1) Analyze the problem2) Plan a solution3) Design an interface

Page 31: CS0004:  Introduction to Programming

Program Development Cycle When Developing a program in both the real

world AND in this class, there are 6 steps:1) Analyze the problem2) Plan a solution3) Design an interface4) Write the code

Page 32: CS0004:  Introduction to Programming

Program Development Cycle When Developing a program in both the real

world AND in this class, there are 6 steps:1) Analyze the problem2) Plan a solution3) Design an interface4) Write the code5) Test and debug

Page 33: CS0004:  Introduction to Programming

Program Development Cycle When Developing a program in both the real

world AND in this class, there are 6 steps:1) Analyze the problem2) Plan a solution3) Design an interface4) Write the code5) Test and debug6) Document the program

Page 34: CS0004:  Introduction to Programming

Program Development Cycle When Developing a program in both the real

world AND in this class, there are 6 steps1) Analyze the problem2) Plan a solution3) Design an interface4) Write the code5) Test and debug6) Document the program7) (Not done in this class) Maintain the program

Page 35: CS0004:  Introduction to Programming

Program Development Cycle When Developing a program in both the real

world AND in this class, there are 6 steps1) Analyze the problem2) Plan a solution3) Design an interface4) Write the code5) Test and debug6) Document the program7) (Not done in this class) Maintain the program To be successful in this class, you must

perform each of these steps.

Page 36: CS0004:  Introduction to Programming

Analyze the Problem Understand what the problem is and what the

solution should be

Page 37: CS0004:  Introduction to Programming

Analyze the Problem Understand what the problem is and what the

solution should be Keep in mind what the End User should be

able to see and do.

Page 38: CS0004:  Introduction to Programming

Analyze the Problem Understand what the problem is and what the

solution should be Keep in mind what the End User should be

able to see and do. User –

Page 39: CS0004:  Introduction to Programming

Analyze the Problem Understand what the problem is and what the

solution should be Keep in mind what the End User should be

able to see and do. User – Anyone who uses the program.

Page 40: CS0004:  Introduction to Programming

Analyze the Problem Understand what the problem is and what the

solution should be Keep in mind what the End User should be

able to see and do. User – Anyone who uses the program.

End User –

Page 41: CS0004:  Introduction to Programming

Analyze the Problem Understand what the problem is and what the

solution should be Keep in mind what the End User should be

able to see and do. User – Anyone who uses the program.

End User – The person whom the program was designed for him/her to use.

Page 42: CS0004:  Introduction to Programming

Analyze the Problem Understand what the problem is and what the

solution should be Keep in mind what the End User should be

able to see and do. User – Anyone who uses the program.

End User – The person whom the program was designed for him/her to use.

Also keep in mind what the CORRECT solution to the problem is.

Page 43: CS0004:  Introduction to Programming

Analyze the Problem Understand what the problem is and what the

solution should be Keep in mind what the End User should be

able to see and do. User – Anyone who uses the program.

End User – The person whom the program was designed for him/her to use.

Also keep in mind what the CORRECT solution to the problem is.

This needs to be done before ANY of the following steps can take place.

Page 44: CS0004:  Introduction to Programming

Analyze the Problem Understand what the problem is and what the

solution should be Keep in mind what the End User should be able to

see and do. User – Anyone who uses the program.

End User – The person whom the program was designed for him/her to use.

Also keep in mind what the CORRECT solution to the problem is.

This needs to be done before ANY of the following steps can take place.

People have this job in real life: http://en.wikipedia.org/wiki/Software_analyst

Page 45: CS0004:  Introduction to Programming

Analyze the Problem Understand what the problem is and what the

solution should be Keep in mind what the End User should be able to

see and do. User – Anyone who uses the program.

End User – The person whom the program was designed for him/her to use.

Also keep in mind what the CORRECT solution to the problem is.

This needs to be done before ANY of the following steps can take place.

People have this job in real life: http://en.wikipedia.org/wiki/Software_analyst

Page 46: CS0004:  Introduction to Programming

Plan a Solution Once you understand the problem, you can

develop an algorithm.

Page 47: CS0004:  Introduction to Programming

Plan a Solution Once you understand the problem, you can

develop an algorithm. Create precise steps for the entire flow of the

program. Usually in the form of:

Page 48: CS0004:  Introduction to Programming

Plan a Solution Once you understand the problem, you can

develop an algorithm. Create precise steps for the entire flow of the

program. Usually in the form of: Get Input

Page 49: CS0004:  Introduction to Programming

Plan a Solution Once you understand the problem, you can

develop an algorithm. Create precise steps for the entire flow of the

program. Usually in the form of: Get Input Validate Input

Page 50: CS0004:  Introduction to Programming

Plan a Solution Once you understand the problem, you can

develop an algorithm. Create precise steps for the entire flow of the

program. Usually in the form of: Get Input Validate Input Manipulate Input

Page 51: CS0004:  Introduction to Programming

Plan a Solution Once you understand the problem, you can

develop an algorithm. Create precise steps for the entire flow of the

program. Usually in the form of: Get Input Validate Input Manipulate Input Output Solution

Page 52: CS0004:  Introduction to Programming

Plan a Solution Once you understand the problem, you can

develop an algorithm. Create precise steps for the entire flow of the

program. Usually in the form of: Get Input Validate Input Manipulate Input Output Solution

Every detail should be covered in the algorithm.

Page 53: CS0004:  Introduction to Programming

Plan a Solution Once you understand the problem, you can

develop an algorithm. Create precise steps for the entire flow of the

program. Usually in the form of: Get Input Validate Input Manipulate Input Output Solution

Every detail should be covered in the algorithm. Consider what is logical and illogical for the

control flow.

Page 54: CS0004:  Introduction to Programming

Plan a Solution Once you understand the problem, you can develop

an algorithm. Create precise steps for the entire flow of the

program. Usually in the form of: Get Input Validate Input Manipulate Input Output Solution

Every detail should be covered in the algorithm. Consider what is logical and illogical for the control

flow. Think about what situations can happen in the

problem.

Page 55: CS0004:  Introduction to Programming

Plan a Solution Once you understand the problem, you can develop an

algorithm. Create precise steps for the entire flow of the program.

Usually in the form of: Get Input Validate Input Manipulate Input Output Solution

Every detail should be covered in the algorithm. Consider what is logical and illogical for the control flow. Think about what situations can happen in the problem. There are many tools programmers use to model the

flow of a program.

Page 56: CS0004:  Introduction to Programming

Plan a Solution Once you understand the problem, you can develop an

algorithm. Create precise steps for the entire flow of the program.

Usually in the form of: Get Input Validate Input Process Input Output Solution

Every detail should be covered in the algorithm. Consider what is logical and illogical for the control flow. Think about what situations can happen in the problem. There are many tools programmers use to model the flow of a

program. In real-world software projects, this is often done by committee

Page 57: CS0004:  Introduction to Programming

Design the Interface An interface is how two component interact

with each other.

Page 58: CS0004:  Introduction to Programming

Design the Interface An interface is how two component interact

with each other. User Interface – How the user interact with your

program.

Page 59: CS0004:  Introduction to Programming

Design the Interface An interface is how two component interact

with each other. User Interface – How the user interact with your

program. Think about how you allow the end user to

interact with you program.

Page 60: CS0004:  Introduction to Programming

Design the Interface An interface is how two component interact

with each other. User Interface – How the user interact with your

program. Think about how you allow the end user to

interact with you program. Consider how the user inputs data and views

results.

Page 61: CS0004:  Introduction to Programming

Design the Interface An interface is how two component interact

with each other. User Interface – How the user interact with your

program. Think about how you allow the end user to

interact with you program. Consider how the user inputs data and views

results. Think about what makes sense to the end

user.

Page 62: CS0004:  Introduction to Programming

Design the Interface An interface is how two component interact

with each other. User Interface – How the user interact with your

program. Think about how you allow the end user to

interact with you program. Consider how the user inputs data and views

results. Think about what makes sense to the end

user. Visual Basic is good for this.

Page 63: CS0004:  Introduction to Programming

Design the Interface An interface is how two component interact

with each other. User Interface – How the user interact with your

program. Think about how you allow the end user to

interact with you program. Consider how the user inputs data and views

results. Think about what makes sense to the end

user. Visual Basic is good for this. For this course, this includes windows,

buttons, text boxes, etc.

Page 64: CS0004:  Introduction to Programming

Design the Interface An interface is how two component interact with each

other. User Interface – How the user interact with your program.

Think about how you allow the end user to interact with you program.

Consider how the user inputs data and views results. Think about what makes sense to the end user. Visual Basic is good for this. For this course, this includes windows, buttons, text

boxes, etc. Again, this is a job in real life: http://

en.wikipedia.org/wiki/User_interface_design

Page 65: CS0004:  Introduction to Programming

Write the Code Writing code is a process of translating the

algorithm you developed into a programming language.

Page 66: CS0004:  Introduction to Programming

Write the Code Writing code is a process of translating the

algorithm you developed into a programming language.

Coding – technical word for writing code.

Page 67: CS0004:  Introduction to Programming

Write the Code Writing code is a process of translating the

algorithm you developed into a programming language.

Coding – technical word for writing code. This is where knowledge of a programming

language (VB in our case) is used.

Page 68: CS0004:  Introduction to Programming

Write the Code Writing code is a process of translating the

algorithm you developed into a programming language.

Coding – technical word for writing code. This is where knowledge of a programming

language (VB in our case) is used. Again, this is a real-world job: http://

en.wikipedia.org/wiki/Software_developer http://en.wikipedia.org/wiki/Software_engineer

Page 69: CS0004:  Introduction to Programming

Testing and Debugging Bug -

Page 70: CS0004:  Introduction to Programming

Testing and Debugging Bug - an error, flaw, mistake, failure, or fault in

a computer program Even experienced software engineers make

mistakes, so it is important to test your program for errors.

Page 71: CS0004:  Introduction to Programming

Testing and Debugging Bug - an error, flaw, mistake, failure, or fault in

a computer program Even experienced software engineers make

mistakes, so it is important to test your program for errors.

Two Kinds (of many) of Errors:

Page 72: CS0004:  Introduction to Programming

Testing and Debugging Bug - an error, flaw, mistake, failure, or fault in

a computer program Even experienced software engineers make

mistakes, so it is important to test your program for errors.

Two Kinds (of many) of Errors: Syntax Error – Error in typing the program.

Page 73: CS0004:  Introduction to Programming

Testing and Debugging Bug - an error, flaw, mistake, failure, or fault in

a computer program Even experienced software engineers make

mistakes, so it is important to test your program for errors.

Two Kinds (of many) of Errors: Syntax Error – Error in typing the program. Logical Error – Inconsistency between what you

want the program to do and what it actually does.

Page 74: CS0004:  Introduction to Programming

Testing and Debugging Bug - an error, flaw, mistake, failure, or fault in

a computer program Even experienced software engineers make

mistakes, so it is important to test your program for errors.

Two Kinds (of many) of Errors: Syntax Error – Error in typing the program. Logical Error – Inconsistency between what you

want the program to do and what it actually does. It’s important to consider all normal and

abnormal inputs for the program.

Page 75: CS0004:  Introduction to Programming

Testing and Debugging Bug - an error, flaw, mistake, failure, or fault in a

computer program Even experienced software engineers make

mistakes, so it is important to test your program for errors.

Two Kinds (of many) of Errors: Syntax Error – Error in typing the program. Logical Error – Inconsistency between what you want the

program to do and what it actually does. It’s important to consider all normal and abnormal

inputs for the program. Actual Job: http://

en.wikipedia.org/wiki/Software_tester

Page 76: CS0004:  Introduction to Programming

Complete the Documentation Documentation – Organizing all the material

that describes the program.

Page 77: CS0004:  Introduction to Programming

Complete the Documentation Documentation – Organizing all the material

that describes the program. Documentation includes:

Page 78: CS0004:  Introduction to Programming

Complete the Documentation Documentation – Organizing all the material

that describes the program. Documentation includes:

Comments inside of the code document that describes to whoever reads it what specific sections do.

Page 79: CS0004:  Introduction to Programming

Complete the Documentation Documentation – Organizing all the material

that describes the program. Documentation includes:

Comments inside of the code document that describes to whoever reads it what specific sections do.

Comments inside of the code that describe the who the author is, when it was written, and any other relevant information

Page 80: CS0004:  Introduction to Programming

Complete the Documentation Documentation – Organizing all the material

that describes the program. Documentation includes:

Comments inside of the code document that describes to whoever reads it what specific sections do.

Comments inside of the code that describe the who the author is, when it was written, and any other relevant information

In commercial settings (industry) this includes user manuals that describe how to use the program.

Page 81: CS0004:  Introduction to Programming

Complete the Documentation Documentation – Organizing all the material that

describes the program. Documentation includes:

Comments inside of the code document that describes to whoever reads it what specific sections do.

Comments inside of the code that describe the who the author is, when it was written, and any other relevant information

In commercial settings (industry) this includes user manuals that describe how to use the program.

This may seem annoying, but it is a very important requirement for this course.

Page 82: CS0004:  Introduction to Programming

Complete the Documentation Documentation – Organizing all the material that

describes the program. Documentation includes:

Comments inside of the code document that describes to whoever reads it what specific sections do.

Comments inside of the code that describe the who the author is, when it was written, and any other relevant information

In commercial settings (industry) this includes user manuals that describe how to use the program.

This may seem annoying, but it is a very important requirement for this course.

It is easiest to document code WHILE writing it, as well as completing it once finished writing code.

Page 83: CS0004:  Introduction to Programming

Modeling Tools To help understand the steps of an algorithm,

programmers use a variety of tools.

Page 84: CS0004:  Introduction to Programming

Modeling Tools To help understand the steps of an algorithm,

programmers use a variety of tools to model the algorithm.

Three that will help us in this class are:

Page 85: CS0004:  Introduction to Programming

Modeling Tools To help understand the steps of an algorithm,

programmers use a variety of tools Three that will help us in this class are:

Flowcharts – Graphically depict the logical steps to carry out a task and show how the steps relate to each other

Page 86: CS0004:  Introduction to Programming

Modeling Tools To help understand the steps of an algorithm,

programmers use a variety of tools Three that will help us in this class are:

Flowcharts – Graphically depict the logical steps to carry out a task and show how the steps relate to each other

Pseudocode – English-like phrases with some Visual Basic terms to outline the task

Page 87: CS0004:  Introduction to Programming

Modeling Tools To help understand the steps of an algorithm,

programmers use a variety of tools Three that will help us in this class are:

Flowcharts – Graphically depict the logical steps to carry out a task and show how the steps relate to each other

Pseudocode – English-like phrases with some Visual Basic terms to outline the task

Hierarchy Charts – Show how the different parts of a program relate to each other.

Page 88: CS0004:  Introduction to Programming

Developing an Algorithm Consider the problem of finding out how many

stamps you need to put on an envelope to mail it.

Page 89: CS0004:  Introduction to Programming

Developing an Algorithm Consider the problem of finding out how many

stamps you need to put on an envelope to mail it.

The rule here is that you need 1 stamp for every 5 sheets of paper in the envelope.

Page 90: CS0004:  Introduction to Programming

Developing an Algorithm Consider the problem of finding out how many

stamps you need to put on an envelope to mail it.

The rule here is that you need 1 stamp for every 5 sheets of paper in the envelope.

So the algorithm looks something like this:

Page 91: CS0004:  Introduction to Programming

Developing an Algorithm Consider the problem of finding out how many

stamps you need to put on an envelope to mail it.

The rule here is that you need 1 stamp for every 5 sheets of paper in the envelope.

So the algorithm looks something like this:1. Get the number of sheets from the user.

Page 92: CS0004:  Introduction to Programming

Developing an Algorithm Consider the problem of finding out how many

stamps you need to put on an envelope to mail it.

The rule here is that you need 1 stamp for every 5 sheets of paper in the envelope.

So the algorithm looks something like this:1. Get the number of sheets from the user.2. Divide the number of sheets by 5

Page 93: CS0004:  Introduction to Programming

Developing an Algorithm Consider the problem of finding out how many

stamps you need to put on an envelope to mail it.

The rule here is that you need 1 stamp for every 5 sheets of paper in the envelope.

So the algorithm looks something like this:1. Get the number of sheets from the user.2. Divide the number of sheets by 53. Round the result from step 2 the highest

whole number

Page 94: CS0004:  Introduction to Programming

Developing an Algorithm Consider the problem of finding out how many

stamps you need to put on an envelope to mail it.

The rule here is that you need 1 stamp for every 5 sheets of paper in the envelope.

So the algorithm looks something like this:1. Get the number of sheets from the user.2. Divide the number of sheets by 53. Round the result from step 2 the highest

whole number4. Output the number of stamps

Page 95: CS0004:  Introduction to Programming

Developing an Algorithm Consider the problem of finding out how many

stamps you need to put on an envelope to mail it. The rule here is that you need 1 stamp for every 5

sheets of paper in the envelope. So the algorithm looks something like this:1. Get the number of sheets from the user.2. Divide the number of sheets by 53. Round the result from step 2 the highest whole

number4. Output the number of stamps Let’s see how the three modeling tools work here

Page 96: CS0004:  Introduction to Programming

Developing an Algorithm Consider the problem of finding out how many

stamps you need to put on an envelope to mail it. The rule here is that you need 1 stamp for every 5

sheets of paper in the envelope. So the algorithm looks something like this:1. Get the number of sheets from the user.2. Divide the number of sheets by 53. Round the result from step 2 the highest whole

number4. Output the number of stamps Let’s see how the three modeling tools work here

Page 97: CS0004:  Introduction to Programming

Developing an Algorithm Consider the problem of finding out how many

stamps you need to put on an envelope to mail it. The rule here is that you need 1 stamp for every 5

sheets of paper in the envelope. So the algorithm looks something like this:1. Get the number of sheets from the user. (Input)2. Divide the number of sheets by 5 (Process)3. Round the result from step 2 the highest whole

number (Process)4. Output the number of stamps (Output) Let’s see how the three modeling tools work here

Page 98: CS0004:  Introduction to Programming

Developing an Algorithm So a specific example looks like

Page 99: CS0004:  Introduction to Programming

Developing an Algorithm So a specific example looks like 1. The user inputs 16 sheets of paper

Page 100: CS0004:  Introduction to Programming

Developing an Algorithm So a specific example looks like 1. The user inputs 16 sheets of paper2. Dividing 16 by 5 results in 3.2

Page 101: CS0004:  Introduction to Programming

Developing an Algorithm So a specific example looks like 1. The user inputs 16 sheets of paper2. Dividing 16 by 5 results in 3.23. Rounding 3.2 up results in 4

Page 102: CS0004:  Introduction to Programming

Developing an Algorithm So a specific example looks like 1. The user inputs 16 sheets of paper2. Dividing 16 by 5 results in 3.23. Rounding 3.2 up results in 44. Output 4 stamps

Page 103: CS0004:  Introduction to Programming

Developing an Algorithm So a specific example looks like 1. The user inputs 16 sheets of paper2. Dividing 16 by 5 results in 3.23. Rounding 3.2 up results in 44. Output 4 stamps Simple enough, right? What could go

wrong?

Page 104: CS0004:  Introduction to Programming

Developing an Algorithm So a specific example looks like 1. The user inputs 16 sheets of paper2. Dividing 16 by 5 results in 3.23. Rounding 3.2 up results in 44. Output 4 stamps Simple enough, right? What could go

wrong? What if the user inputs “Banana” sheets of

paper?

Page 105: CS0004:  Introduction to Programming

Developing an Algorithm Revised Algorithm:1. Get the number of sheets from the user.

(Input)

Page 106: CS0004:  Introduction to Programming

Developing an Algorithm Revised Algorithm:1. Get the number of sheets from the user.

(Input)2. Check to see if the input is a positive

number. (Validate)

Page 107: CS0004:  Introduction to Programming

Developing an Algorithm Revised Algorithm:1. Get the number of sheets from the user.

(Input)2. Check to see if the input is a positive

number. (Validate)3. Divide the number of sheets by 5 (Process)4. Round the result from step 2 the highest

whole number (Process)5. Output the number of stamps (Output) Now that our algorithm is set, lets see how

the modeling tools work.

Page 108: CS0004:  Introduction to Programming

Developing an Algorithm Revised Algorithm:1. Get the number of sheets from the user.

(Input)2. Check to see if the input is a positive

number. (Validate)3. Divide the number of sheets by 5 (Process)

Page 109: CS0004:  Introduction to Programming

Developing an Algorithm Revised Algorithm:1. Get the number of sheets from the user.

(Input)2. Check to see if the input is a positive

number. (Validate)3. Divide the number of sheets by 5 (Process)4. Round the result from step 2 the highest

whole number (Process)

Page 110: CS0004:  Introduction to Programming

Developing an Algorithm Revised Algorithm:1. Get the number of sheets from the user.

(Input)2. Check to see if the input is a positive

number. (Validate)3. Divide the number of sheets by 5 (Process)4. Round the result from step 2 the highest

whole number (Process)5. Output the number of stamps (Output)

Page 111: CS0004:  Introduction to Programming

Developing an Algorithm Revised Algorithm:1. Get the number of sheets from the user.

(Input)2. Check to see if the input is a positive

number. (Validate)3. Divide the number of sheets by 5 (Process)4. Round the result from step 2 the highest

whole number (Process)5. Output the number of stamps (Output) Now that our algorithm is set, lets see how

the modeling tools work.

Page 112: CS0004:  Introduction to Programming

Hierarchy ChartsPostage Stamp Program

Page 113: CS0004:  Introduction to Programming

Hierarchy ChartsPostage Stamp Program

Read Sheets Calculate Stamps Display Stamps

Page 114: CS0004:  Introduction to Programming

Hierarchy ChartsPostage Stamp Program

Read Sheets Calculate Stamps Display Stamps

Getsheets

Make suresheets is

a positive integer.

Page 115: CS0004:  Introduction to Programming

Hierarchy ChartsPostage Stamp Program

Read Sheets Calculate Stamps Display Stamps

Getsheets

Make suresheets is

a positive integer.

Must benumber

Must bepositive

Must be

integer

Page 116: CS0004:  Introduction to Programming

Hierarchy ChartsPostage Stamp Program

Read Sheets Calculate Stamps Display Stamps

Getsheets

Make suresheets is

a positive integer.

Set stamps =sheets / 5

Round stampsup to next whole

number

Must benumber

Must bepositive

Must be

integer

Page 117: CS0004:  Introduction to Programming

Hierarchy ChartsPostage Stamp Program

Read Sheets Calculate Stamps Display Stamps

Getsheets

Make suresheets is

a positive integer.

Display:"You will need: "

# of stampsSet stamps =sheets / 5

Round stampsup to next whole

number

Must benumber

Must bepositive

Must be

integer

Page 118: CS0004:  Introduction to Programming

Hierarchy Charts Good for showing the structure of the

algorithm

Page 119: CS0004:  Introduction to Programming

Hierarchy Charts Good for showing the structure of the

algorithm Good at breaking down the algorithm into

components

Page 120: CS0004:  Introduction to Programming

Hierarchy Charts Good for showing the structure of the

algorithm Good at breaking down the algorithm into

components Not too great at showing the order of events

Page 121: CS0004:  Introduction to Programming

Hierarchy Charts Good for showing the structure of the

algorithm Good at breaking down the algorithm into

components Not too great at showing the order of events Flow Charts are better at showing the order in

which the components execute.

Page 122: CS0004:  Introduction to Programming

Flow Charts Components

Page 123: CS0004:  Introduction to Programming

Flow Charts Components Flow Line - indicates the flow of logic

Page 124: CS0004:  Introduction to Programming

Flow Charts Components Flow Line - indicates the flow of logic

Terminal – indicates the start or end of a task

Page 125: CS0004:  Introduction to Programming

Flow Charts Components Flow Line - indicates the flow of logic

Terminal – indicates the start or end of a task

Input/Output – used for input or output operations. What is to be input or output should be in the figure.

Page 126: CS0004:  Introduction to Programming

Flow Charts Processing - used to show a processing step.

The instructions are displayed in the figure.

Page 127: CS0004:  Introduction to Programming

Flow Charts Processing - used to show a processing step.

The instructions are displayed in the figure.

Decision – used to show when a decision needs to be made. Lines for yes and no come out of it. The question is displayed in the figure.

Page 128: CS0004:  Introduction to Programming

Flow Charts Processing - used to show a processing step.

The instructions are displayed in the figure.

Decision – used to show when a decision needs to be made. Lines for yes and no come out of it. The question is displayed in the figure.

Connector – Used to join flow lines.

Page 129: CS0004:  Introduction to Programming

Flow ChartsStart

Page 130: CS0004:  Introduction to Programming

Flow ChartsStart

Read sheet

s

Page 131: CS0004:  Introduction to Programming

Flow ChartsStart

Read sheet

sIs sheets positiv

e numbe

r?

No

Yes

Page 132: CS0004:  Introduction to Programming

Flow ChartsStart

Set stamps = sheets / 5

Read sheet

sIs sheets positiv

e numbe

r?

No

Yes

Page 133: CS0004:  Introduction to Programming

Flow ChartsStart

Set stamps = sheets / 5

Read sheet

sIs sheets positiv

e numbe

r?

Round stamps up

to next whole

number

No

Yes

Page 134: CS0004:  Introduction to Programming

Flow ChartsStart

Set stamps = sheets / 5

Read sheet

sIs sheets positiv

e numbe

r?

Round stamps up

to next whole

numberDisplay: "You will need: " #stamps

No

Yes

Page 135: CS0004:  Introduction to Programming

Flow ChartsStart

Set stamps = sheets / 5

Read sheet

sIs sheets positiv

e numbe

r?

Round stamps up

to next whole

numberDisplay: "You will need: " #stamps

End

No

Yes

Page 136: CS0004:  Introduction to Programming

Flow ChartsStart

Set stamps = sheets / 5

Read sheet

sIs sheets positiv

e numbe

r?

Round stamps up

to next whole

numberDisplay: "You will need: " #stamps

End

Display error

message

No

Yes

Page 137: CS0004:  Introduction to Programming

Flow ChartsStart

Set stamps = sheets / 5

Read sheet

sIs sheets positiv

e numbe

r?

Round stamps up

to next whole

numberDisplay: "You will need: " #stamps

End

Display error

message

No

Yes

Page 138: CS0004:  Introduction to Programming

Pseudocode This will become more clear when you

understand VB terms better.

Page 139: CS0004:  Introduction to Programming

Pseudocode This will become more clear when you

understand VB terms better. Pseudocode is good for listing the steps of an

algorithm in a form that is easier to translate into VB.

Page 140: CS0004:  Introduction to Programming

Pseudocode This will become more clear when you

understand VB terms better. Pseudocode is good for listing the steps of an

algorithm in a form that is easier to translate into VB.

Important: There is NO SPECIFIC FORM to pseudocode, it can look as much like VB or English as you want. The more VB you learn, the more VB-like pseudocode you can write.

Page 141: CS0004:  Introduction to Programming

PseudocodeProgram: Determine the proper number of

steps for a letterRead sheetsif sheets is a positive integer

Stamps = Sheets/5Whole Stamps = Stamps rounded to next whole numberOutput Whole Stamps

elseDisplay Error


Recommended