Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 2 I Am Not a Control Freak!

Slides:



Advertisements
Similar presentations
CS101: Introduction to Computer programming
Advertisements

Programming with Microsoft Visual Basic 2008 Fourth Edition
Program Flowchart, Pseudocode & Algorithm development
Introduction to Flowcharting
Understanding the Three Basic Structures
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
Subject: Information Technology Grade: 10
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
Fundamentals of Algorithms MCS - 2 Lecture # 4
Basics of Computer Programming Web Design Section 8-1.
8 Algorithms Foundations of Computer Science ã Cengage Learning.
ITEC113 Algorithms and Programming Techniques
CS 1400 Course Reader Introduction. What is Programming? Designing an appropriate algorithm Coding that algorithm in a computer language.
Percents, Discounts and Interest PERCENTS: A percent is a representation of a number, compared to a total value of 100. A percent which is less than a.
What is an algorithm? Informally: An Algorithm is a step by step method for solving a problem. It’s purpose is to break a larger task down so that each.
Defining Control Structures
An Introduction to Programming with C++ Fifth Edition Chapter 1 An Introduction to Programming.
Chapter 3 Planning Your Solution
(C)opyright 2003 Scott/Jones Publishers Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Scott/Jones Publishers.
Business Math Assignment Press F5 to begin to playing this slide show.
CSC103: Introduction to Computer and Programming
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Multiplication is the process of adding equal sets together = 6 We added 2 three times.
An Introduction to Programming with C++ Sixth Edition
Chapter 12: How Long Can This Go On?
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
Problem Solving with Decisions
S2008Final_part1.ppt CS11 Introduction to Programming Final Exam Part 1 S A computer is a mechanical or electrical device which stores, retrieves,
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Chapter 6: The Repetition Structure
ITEC113 Algorithms and Programming Techniques
Chapter 1: An Introduction to Control Structures Introduction to Programming with C++ Fourth Edition.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Flowcharting & Algorithms. Quick. Close your Eyes and Listen You are still sitting in the classroom. However, you have been called to the counselor’s.
`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.
A item is marked 25% off and then you are given an additional discount of 10%. What will you pay? Are receiving a total of 35% off? Explain why or why.
(C)opyright 2000 Scott/Jones Publishers Introduction to Flowcharting.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding the Three Basic Structures Structure: a basic unit of programming logic Any program.
INTRODUCTION TO PROGRAMMING. Program Development Life Cycle The program development life cycle is a model that describes the stages involved in a program.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
CS 101 – Oct. 7 Solving simple problems: create algorithm Structure of solution –Sequence of steps (1,2,3….) –Sometimes we need to make a choice –Sometimes.
1 VB-04-Control Structures 16 March 2016 Visual Basic Control Structures - Selection.
Introduction to Flowcharts
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
CIS 115 All Exercises Devry University (Devry) FOR MORE CLASSES VISIT CIS 115 All Exercises Devry University.
An Introduction to Programming with C++1 An Introduction to Control Structures Tutorial 1.
Introduction to Programming in C++ Seventh Edition Chapter 1: An Introduction to Programming.
CIS 115 Slingshot Academy / cis115.com
ALGORITHMS AND FLOWCHARTS
Exercise : Write a program that print the final price of purchase at a store where everything costs exactly one dollar. Ask for the number of items purchased.
Basics of Computer Programming
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to Programming
Basics of Computer Programming
Basics of Computer Programming
Basics of Computer Programming
Transition to Code Upsorn Praphamontripong CS 1111
An Introduction to Control Structures
Understanding the Three Basic Structures
Introduction to Algorithms and Programming
` Structured Programming & Flowchart
Algorithm and Ambiguity
Early - I can develop a sequence of instructions and run them using programmable devices or equivalent Designs a simple sequence of instructions/algorithm.
Computer Science Core Concepts
An Introduction to Control Structures
Chapter 2 Control Structures.
An Introduction to Programming with C++ Fifth Edition
Presentation transcript:

Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 2 I Am Not a Control Freak!

Clearly Visual Basic: Programming with Visual Basic 2008 Objectives Describe the three control structures Write simple algorithms using the sequence, selection, and repetition structures 2

Clearly Visual Basic: Programming with Visual Basic 2008 Control Structures Control structures –Sequence, selection, and repetition –Control the flow of a program’s logic Most programs –Will use both selection and repetition structures 3

Clearly Visual Basic: Programming with Visual Basic 2008 The Sequence Structure Directs computer to process program instructions in a particular order Example: Rob, the mechanical man –Has a limited instruction set Algorithm –Set of step-by-step instructions that accomplish a task 4

Clearly Visual Basic: Programming with Visual Basic 20085

The Selection Structure Also called the decision structure Makes a decision and then takes appropriate action based on that decision Used every time you drive your car and approach an intersection 6

Clearly Visual Basic: Programming with Visual Basic 20087

The Repetition Structure Directs computer to repeat one or more instructions until some condition is met Also referred to as a loop or as iteration 8

Clearly Visual Basic: Programming with Visual Basic 20089

Summary Algorithm –Set of step-by-step instructions that accomplish a task Control structures –Sequence, selection, and repetition –Also called logic structures Sequence structure –Directs computer to process program instructions one after another 10

Clearly Visual Basic: Programming with Visual Basic 2008 Summary (continued) Selection structure –Directs computer to make a decision and then selects appropriate action to take Repetition structure –Directs computer to repeat one or more program instructions until some condition is met Sequence structure –Used in all programs 11

Review Questions – Page 13 1.The set of instructions for adding together 2 numbers: control, repetition, selection, or sequence 2.The recipe instruction “beat until smooth: control, repetition, selection, or sequence 3.The instruction “If it rains outside, then take an umbrella to work: control, repetition, selection, or sequence 4.Which control is used to determine if a credit card holder is over his credit limit: repetition, selection, both repetition and sequence 5.A company pays 3% annual bonus to employees who have been with the company more than 5 years; others get 1% bonus. Which is used to calculate every bonus? repetition, selection, both repetition and sequence

Answers to Page 13 Sequence Repetition Selection Both repetition and selection Clearly Visual Basic: Programming with Visual Basic

Exercise – Page 14 & 15 Do first two together- divide other problems between groups of students Group 1 take prob. 3, Group 2 take prob. 4, Group 3 take prob. 5, Group 4 take prob. 6 Walk Forward, sit down, stand up, pick the flower with your right hand, pick the flower with your left hand, drop the toy in the toy chest, turn right 90 degrees, jump over the box, throw the box out of the way, if the box is red, do this: otherwise do this: repeat x times, repeat until you are directly in front of the chair, repeat until you are directly in front of the toy chest

Continue- Exercises – Page #7: A store gives a 10% discount to customers who are at least 65 years old. Create an algorithm: Assign 10% as the discount rate Assign 0% as the discount rate Calculate the amount due by subtracting discount rate from the number 1, and then multiplying the result times the item price If the customer is greater than or equal to 65, do this: If the customer is less than 65, do this: Otherwise do this: Print the amount due Read the customer’s age and item price

Continue- Exercises – Page #9: Calculates and prints gross pay for 5 employees. If an employee works more than 40 hours, he gets time and a half. Create an algorithm: _________?__________ read the employees name, hours work & pay rate _________?__________ Calculate gross pay = hours worked * 40 otherwise, do this: calculate regular pay= pay rate * 40 calculate overtime hours = hours worked – 40 calculate overtime pay= ____________________ calculate gross pay = ______________________ Print the employee’s name and gross pay

1.Walk into the maze (this is #11: debug the maze program) 2.Turn left 90 degrees 3.Repeat until you are directly in front of a wall: walk forward 4.Turn right 90 degrees 5.Repeat until you are directly in front of a wall: walk forward 6.Turn right 90 degrees 7.Repeat until you are directly in front of a wall: walk forward 8.Turn right 90 degrees 9.Repeat until you are directly in front of a wall: walk forward 10.Turn right 90 degrees 11.Repeat until you are directly in front of a wall: walk forward 12.Turn left 90 degrees 13.Repeat until you are directly in front of a wall: turn right 90 degrees 14.Repeat until you are out of the maze: walk forward