Visual Basic Programming Introduction to Computers Programming
Programming – Why? Computers are used for many different purposes in many different situations. But, how can they be so versatile? Answer: They can be programmed The ability for a computer to be programmed allows it to do whatever their programs tell them what to do. A program is a set of instructions that tell a computer what to do. A computer cannot do anything unless it has a program to tell it what to do. In this class, we will focus on writing these programs.
Programming – What? Programs are used to operate the components of a computer, solve problems or satisfy a want/need. How long will it take me to get home if I drive x miles per hour? I want to be able to tell my friends what I am doing right now. Computer Programming is both an Art and a Science Every aspect of a program must be carefully designed As an art, programming takes creativity and problem solving. There is often no one correct way to solve a problem. As a science, there are formal and proven methods to go about creating a programming. In this course, you will learn both the art and science of programming.
Hardware and Software Programs can also be called software. Software refers to the computer programs that a computer uses to complete a task. Hardware refers to the physical components that a computer is made of. A computer is not one device, but a system of devices working in tandem. Each device plays a part. Major components: Central Processing Unit Main Memory Secondary Storage Devices Input Devices Output Devices
Central Processing Unit (CPU) The CPU is the heart and brain of the computer. The CPU continuously does the following things: 1. Fetch an instruction 2. Follow the instruction 3. Produce some resulting data The CPU has two parts: Control Unit Coordinates the computer’s operations Determines where to get the next instruction Regulates the other major components of the computer Arithmetic and Logic Unit (ALU) Designed to perform mathematical operations
Main Memory Main memory holds information that the CPU needs to access quickly. Namely, the instructions to be executed. When a program is running, some or all of its instructions are in main memory. Memory is divided into sections called bytes that hold equal amount of data. Each section is made up of 8 bits. A Bit is the most basic unit of information a computer can hold. It is a switch that is either on (1) or off (0) Each byte is assigned and can be accessed by its address. A Memory Address is a unique identifying number associated with a byte in memory. Main memory typically is volatile. Volatile Memory – is memory that when it loses power, the contents are erased.
Secondary Storage Secondary Storage is memory that can hold data for a long period of time. Programs are usually stored in secondary storage and loaded into main memory as needed. This forms a hierarchy typically called the memory hierarchy. Common forms of secondary storage: Hard Drive Disk Drive Solid State Drive Removable Storage Floppy Disk CD-ROM USB Drives Other files can be stored in secondary storage: Documents Pictures Whatever else you save on your computer
Input Devices Input is any data the computer collects from the outside world. An Input Device is anything that collects data and sends it to the computer. Common Input Devices: Keyboard Mouse Scanner Digital Camera Disk Drive USB Drive
Output Devices Output is any data the computer sends to the outside world. An Output Device formats data and presents it to the outside world. Common Output Devices: Monitor Printer Disk Drive USB Drive
Software Software refers to the programs that run on a computer. Two main categories (for this class): Operating System (OS) A set of programs that manages a computer’s hardware devices and controls their processes. Most modern operating systems are capable of running multiple programs at once. UNIX, Linux, Mac OS X, and Windows are examples Application Software Programs that make the computer useful for the user Solve specific problems or supply a service Word processors, spreadsheets, databases, etc. This is what we will be developing in this class.
What is a Programming Language? At the lowest level we have Machine Language.
What is a Programming Language? At the lowest level we have Machine Language. Machine Language is a system of instructions and data executed directly by a computer's central processing unit.
What is a Programming Language? At the lowest level we have Machine Language. Machine Language is a system of instructions and data executed directly by a computer's central processing unit. What we will be using is a Higher-Level Language
What is a Programming Language? At the lowest level we have Machine Language. Machine Language is a system of instructions and data executed directly by a computer's central processing unit. What we will be using is a Higher-Level Language Higher-Level Languages consists of instruction that people can understand.
What is a Programming Language? At the lowest level we have Machine Language. Machine Language is a system of instructions and data executed directly by a computer's central processing unit. What we will be using is a Higher-Level Language Higher-Level Languages consists of instruction that people can understand. Examples of Higher-Level Languages: C C++ Java Python Visual Basic
Visual Basic Visual Basic – a third generation event-driven and integrated development environment from Microsoft.
Visual Basic Visual Basic – a third generation event-driven and integrated development environment from Microsoft. Third generation programming languages were created in the 1950s and are arguably the most popular kind of programming languages. They were created to be much more programmer- friendly than the previous generation.
Visual Basic Visual Basic – a third generation event-driven and integrated development environment from Microsoft. Third generation programming languages were created in the 1950s and are arguably the most popular kind of programming languages. They were created to be much more programmer- friendly than the previous generation. Event-driven programming is a paradigm in which the flow of programs are determined by events User Actions Messages from Other Programs
Visual Basic Visual Basic – a third generation event-driven and integrated development environment from Microsoft. Third generation programming languages were created in the 1950s and are arguably the most popular kind of programming languages. They were created to be much more programmer- friendly than the previous generation. Event-driven programming is a paradigm in which the flow of programs are determined by events User Actions Messages from Other Programs Integrated Development Environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development.
So how do we get from VB to a Running Program? First, write program.
So how do we get from VB to a Running Program? First, write program. A program is a collection of instructions.
So how do we get from VB to a Running Program? First, write program. A program is a collection of instructions. Then, we use a compiler.
So how do we get from VB to a Running Program? First, write program. A program is a collection of instructions. Then, we use a compiler. A compiler is a computer program that translates high-level language such as VB in Machine Language.
So how do we get from VB to a Running Program? First, write program. A program is a collection of instructions. Then, we use a compiler. A compiler is a computer program that translates high-level language such as VB in Machine Language. The VB compiler also detects certain types of errors during the translation process.
So how do we get from VB to a Running Program? First, write program. A program is a collection of instructions. Then, we use a compiler. A compiler is a computer program that translates high-level language such as VB in Machine Language. The VB compiler also detects certain types of errors during the translation process. Finally, we can run the program.
So how do we get from VB to a Running Program? First, write program. A program is a collection of instructions. Then, we use a compiler. A compiler is a computer program that translates high-level language such as VB in Machine Language. The VB compiler also detects certain types of errors during the translation process. Finally, we can run the program. Executing the instructions given in the instructions is called running the program.
Review Machine Language
Review Machine Language is a system of instructions and data executed directly by a computer's central processing unit.
Review Machine Language is a system of instructions and data executed directly by a computer's central processing unit. Higher-Level Languages
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.
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
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.
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
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.
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
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.
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
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.
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.
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:
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
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
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
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.
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?
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.
Algorithms vs. Programs An Algorithm is
Algorithms vs. Programs An Algorithm is a step-by-step procedure devised for the purpose of taking in data and producing the correct output.
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.
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.
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.
Program Development Cycle When Developing a program in both the real world AND in this class, there are 6 steps:
Program Development Cycle When Developing a program in both the real world AND in this class, there are 6 steps: 1) Analyze the problem
Program Development Cycle When Developing a program in both the real world AND in this class, there are 6 steps: 1) Analyze the problem 2) Plan a solution
Program Development Cycle When Developing a program in both the real world AND in this class, there are 6 steps: 1) Analyze the problem 2) Plan a solution 3) Design an interface
Program Development Cycle When Developing a program in both the real world AND in this class, there are 6 steps: 1) Analyze the problem 2) Plan a solution 3) Design an interface 4) Write the code
Program Development Cycle When Developing a program in both the real world AND in this class, there are 6 steps: 1) Analyze the problem 2) Plan a solution 3) Design an interface 4) Write the code 5) Test and debug
Program Development Cycle When Developing a program in both the real world AND in this class, there are 6 steps: 1) Analyze the problem 2) Plan a solution 3) Design an interface 4) Write the code 5) Test and debug 6) Document the program
Program Development Cycle When Developing a program in both the real world AND in this class, there are 6 steps 1) Analyze the problem 2) Plan a solution 3) Design an interface 4) Write the code 5) Test and debug 6) Document the program 7) (Not done in this class) Maintain the program
Program Development Cycle When Developing a program in both the real world AND in this class, there are 6 steps 1) Analyze the problem 2) Plan a solution 3) Design an interface 4) Write the code 5) Test and debug 6) Document the program 7) (Not done in this class) Maintain the program To be successful in this class, you must perform each of these steps.
Analyze the Problem Understand what the problem is and what the solution should be
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.
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 –
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.
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 –
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.
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.
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.
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:
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:
Plan a Solution Once you understand the problem, you can develop an algorithm.
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:
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
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
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
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
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.
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.
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.
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.
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
Design the Interface An interface is how two component interact with each other.
Design the Interface An interface is how two component interact with each other. User Interface – How the user interact with your program.
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.
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.
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.
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.
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.
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:
Write the Code Writing code is a process of translating the algorithm you developed into a programming language.
Write the Code Writing code is a process of translating the algorithm you developed into a programming language. Coding – technical word for writing code.
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.
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:
Testing and Debugging Bug -
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.
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:
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.
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.
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.
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:
Complete the Documentation Documentation – Organizing all the material that describes the program.
Complete the Documentation Documentation – Organizing all the material that describes the program. Documentation includes:
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.
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
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.
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.
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.
Modeling Tools To help understand the steps of an algorithm, programmers use a variety of tools.
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:
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
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
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.
Developing an Algorithm Consider the problem of finding out how many stamps you need to put on an envelope to mail it.
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.
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:
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.
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
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 3. Round the result from step 2 the highest whole number
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 3. Round the result from step 2 the highest whole number 4. Output the number of stamps
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 3. Round the result from step 2 the highest whole number 4. Output the number of stamps Let’s see how the three modeling tools work here
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 3. Round the result from step 2 the highest whole number 4. Output the number of stamps Let’s see how the three modeling tools work here
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
Developing an Algorithm So a specific example looks like
Developing an Algorithm So a specific example looks like 1. The user inputs 16 sheets of paper
Developing an Algorithm So a specific example looks like 1. The user inputs 16 sheets of paper 2. Dividing 16 by 5 results in 3.2
Developing an Algorithm So a specific example looks like 1. The user inputs 16 sheets of paper 2. Dividing 16 by 5 results in Rounding 3.2 up results in 4
Developing an Algorithm So a specific example looks like 1. The user inputs 16 sheets of paper 2. Dividing 16 by 5 results in Rounding 3.2 up results in 4 4. Output 4 stamps
Developing an Algorithm So a specific example looks like 1. The user inputs 16 sheets of paper 2. Dividing 16 by 5 results in Rounding 3.2 up results in 4 4. Output 4 stamps Simple enough, right? What could go wrong?
Developing an Algorithm So a specific example looks like 1. The user inputs 16 sheets of paper 2. Dividing 16 by 5 results in Rounding 3.2 up results in 4 4. Output 4 stamps Simple enough, right? What could go wrong? What if the user inputs “Banana” sheets of paper?
Developing an Algorithm Revised Algorithm: 1. Get the number of sheets from the user. (Input)
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)
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.
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)
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)
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)
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.
Hierarchy Charts Postage Stamp Program
Hierarchy Charts Postage Stamp Program Read SheetsCalculate StampsDisplay Stamps
Hierarchy Charts Postage Stamp Program Read SheetsCalculate StampsDisplay Stamps Get sheets Make sure sheets is a positive integer.
Hierarchy Charts Postage Stamp Program Read SheetsCalculate StampsDisplay Stamps Get sheets Make sure sheets is a positive integer. Must be number Must be positive Must be integer
Hierarchy Charts Postage Stamp Program Read SheetsCalculate StampsDisplay Stamps Get sheets Make sure sheets is a positive integer. Set stamps = sheets / 5 Round stamps up to next whole number Must be number Must be positive Must be integer
Hierarchy Charts Postage Stamp Program Read SheetsCalculate StampsDisplay Stamps Get sheets Make sure sheets is a positive integer. Display: "You will need: " # of stamps Set stamps = sheets / 5 Round stamps up to next whole number Must be number Must be positive Must be integer
Hierarchy Charts Good for showing the structure of the algorithm
Hierarchy Charts Good for showing the structure of the algorithm Good at breaking down the algorithm into components
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
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.
Flow Charts Components
Flow Charts Components Flow Line - indicates the flow of logic
Flow Charts Components Flow Line - indicates the flow of logic Terminal – indicates the start or end of a task
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.
Flow Charts Processing - used to show a processing step. The instructions are displayed in the figure.
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.
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.
Flow Charts Start
Flow Charts Start Read sheets
Flow Charts Start Read sheets Is sheets positive number? No Yes
Flow Charts Start Set stamps = sheets / 5 Read sheets Is sheets positive number? No Yes
Flow Charts Start Set stamps = sheets / 5 Read sheets Is sheets positive number? Round stamps up to next whole number No Yes
Flow Charts Start Set stamps = sheets / 5 Read sheets Is sheets positive number? Round stamps up to next whole number Display: "You will need: " #stamps No Yes
Flow Charts Start Set stamps = sheets / 5 Read sheets Is sheets positive number? Round stamps up to next whole number Display: "You will need: " #stamps End No Yes
Flow Charts Start Set stamps = sheets / 5 Read sheets Is sheets positive number? Round stamps up to next whole number Display: "You will need: " #stamps End Display error message No Yes
Flow Charts Start Set stamps = sheets / 5 Read sheets Is sheets positive number? Round stamps up to next whole number Display: "You will need: " #stamps End Display error message No Yes
Pseudocode This will become more clear when you understand VB terms better.
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.
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.
Pseudocode Program: Determine the proper number of steps for a letter Read sheets if sheets is a positive integer Stamps = Sheets/5 Whole Stamps = Stamps rounded to next whole number Output Whole Stamps else Display Error