Selection Structures (Part 1)

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

Problem Solving INFORMATION TECHNOLOGY
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
CS107 Introduction to Computer Science Lecture 2.
CS107: Introduction to Computer Science Lecture 2 Jan 29th.
Programming Example: tax computation. Introduction In this webpage, we will study a programming example using the conditional statements (if and if-else)
PROBLEM SOLVING TECHNIQUES
Section 5.2 Normal Distributions: Finding Probabilities.
ISP 121 Algorithmsand Computer Programming. Why Know Simple Programming?  You can create powerful macros in Access / Excel / Word / ??? to manipulate.
From the WS on Changing Tires 4
5.1 Accumulated Changes Example 1: An objects travels with a velocity of 15 mph. What is the distance traveled after 4 hours t v Distance = area.
CS107 Introduction to Computer Science
1 Lab-1 CSIT-121 Spring 2005 Lab Targets Solving problems on computer Programming in C++ Writing and Running Programs Programming Exercise.
Designing Algorithms February 2nd. Administrativia Lab assignments will be due every Monday Lab access –Searles 128: daily until 4pm unless class in progress.
CS107 Introduction to Computer Science Lecture 2.
Designing Algorithms Csci 107 Lecture 3. Designing algorithms Last time –Pseudocode –Algorithm: computing the sum 1+2+…+n –Gauss formula for 1+2+…+n Today.
CS107 Introduction to Computer Science Lecture 5, 6 An Introduction to Algorithms: List variables.
Designing Algorithms Csci 107 Lecture 3. Administrativia Lab access –Searles 128: daily until 4pm unless class in progress –Searles 117: 6-10pm, Sat-Sun.
1 Lab Assignment#5 Due 12/7 A car can hold 12 gallons of gasoline and it can travel 360 miles without refuelling. Write a program the displays the trip.
1 Lab-1 CSIT-121 Fall 2004 Lab Targets Solving problems on computer Programming in C++ Writing and Running Programs Programming Exercise.
JavaScript with Input & Output Step 1: Use tags JavaScript Template.
Review Algorithm Analysis Problem Solving Space Complexity
Using ratios to find distances with miles per gallon.
CSEB114: Principle of programming
Hybrid Fuel Economy All statistics were recorded using a Toyota Prius Hybrid. This is real time data that began in 1/31/11 and continues today. In about.
Introduction to Algorithms. What is Computer Science? Computer Science is the study of computers (??) This leaves aside the theoretical work in CS, which.
Writing Program Code in BASIC Write a program to prompt for and accept values into TWO variables, numx and numy. The program should square the value stored.
Value and Reference Parameters. CSCE 1062 Outline  Summary of value parameters  Summary of reference parameters  Argument/Parameter list correspondence.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Basic Control Structures
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
Copyright 2014 © W. Seth Hunter ConsumerMath.org L2.3 The Cost of Gas I get paid weekly, but pay bills monthly. How can I be sure I am not going to run.
The MPG Illusion. Fuel Efficiency Ace drives a car that averages 10 mpg and is considering trading it in on a new car that averages 12 mpg. Buddy drives.
1. Understand the application of Pseudo Code for programming purposes 2. Be able to write algorithms in Pseudo Code.
CSEB114: PRINCIPLE OF PROGRAMMING Quiz 1. Rules  No cheating  No reference  No discussion  Only best 5 quizzes will be counted in your final marks,
The IF-statements 31-Jan-2005 Venkatesh Ramamoorthy.
Michigan Road Trip. Round Trip AB 0 50 Your trip starts at point A, and you drive to point B. That is considered “one way”. You have to drive back from.
RATES LESSON 46POWER UP JPAGE 329. RATES  Miles per hour (mph)  Miles per gallon (mpg)  Dollars per hour  Per: to divide.
Solving Story Problems Involving Rates. Example #1 Jack drove an average of 55 mph on his trip. He spent a total of 8.5 hours driving. How far did he.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
Transportation Erika Grether Meghan Lockwood. How Have US Driving Habits Changed Since 1970?
Algorithms, Part 3 of 3 Topics In-Class Project: The Box
3.1.3 Program Flow control Structured programming – SELECTION in greater detail.
UNIT RATE 7 th Grade Math. UNIT RATE  To find the Unit Rate, you would find the cost or amount for 1. Or the rate when the denominator is 1.  “How much.
Problem Solving Intro to Computer Science CS1510 Dr. Sarah Diesburg 1.
CS305j Introduction to Computing Parameters Case Study 1 Topic 10 Parameters Case Study " Thinking like a computer scientist means more than being able.
Every other Friday, employees of Burger King get paid. They receiver their hourly wage for every hour they worked. Uncle Sam taxes their earnings taking.
SEMESTER 1 FINAL REVIEW B I have created a pile of sheets. Take a sheet. Work on the sheet. You have been taught how to ‘do this sheet.’ At 11:00 we will.
IT 210 Week 6 CheckPoint Algorithm Verification To purchase this material link CheckPoint-Algorithm-Verification.
Learn to divide decimals.
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.
Introduction to Algorithms
Speed and Velocity.
Chapter 2: Graphing & Geometry
Algorithms and Flowcharts
Introduction to Graphing
Numbering System TODAY AND TOMORROW 11th Edition
Write, interpret, and use the distance formula.
Do Now Multiply   (-19.21)  (–2.1)
Intro to Computer Science CS1510 Dr. Sarah Diesburg
The velocity is constant and the distance is:
Algorithm Discovery and Design
Chapter 5: Control Structure
Programming Concepts and Database
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Intro to Computer Science CS1510 Dr. Sarah Diesburg
The velocity is constant and the distance is:
Lesson Quizzes Standard Lesson Quiz
Minitab and You.
CS 1111 Introduction to Programming Spring 2019
Presentation transcript:

Selection Structures (Part 1) by Yonglei Tao

Conditional Statements Write an algorithm that asks the user for two numbers, and print the larger one. Get the values of a, b from user If the value of a is greater than the value of b then print “The larger number is ” & a Else print “The larger number is ” & b Test 1: What does the program print if the user enters 10, 3? Test 2: What does the program print if the user enters 2, 11?

Conditional Statements (Cont.) Write an algorithm to compute the distance traveled and the average miles per gallon on a trip when given as input the number of gallons used and the starting and ending mileage readings on the odometer. get gallons, start, end distance = end – start mpg = distance / gallons print mpg if mpg > 25.0 then print “You are getting good gas mileage”

Example One

Flowchart

Example Two

Flowchart

Example Three

The Select Case Statement

Example Four

Problem Specification